enetc: Fix an off by one in enetc_setup_tc_txtime()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 7 Jan 2020 13:11:43 +0000 (16:11 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 7 Jan 2020 21:46:20 +0000 (13:46 -0800)
The priv->tx_ring[] has 16 elements but only priv->num_tx_rings are
set up, the rest are NULL.  This ">" comparison should be ">=" to avoid
a potential crash.

Fixes: 0d08c9ec7d6e ("enetc: add support time specific departure base on the qos etf")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/enetc/enetc_qos.c

index e910aaf..00382b7 100644 (file)
@@ -315,7 +315,7 @@ int enetc_setup_tc_txtime(struct net_device *ndev, void *type_data)
 
        tc = qopt->queue;
 
-       if (tc < 0 || tc > priv->num_tx_rings)
+       if (tc < 0 || tc >= priv->num_tx_rings)
                return -EINVAL;
 
        /* Do not support TXSTART and TX CSUM offload simutaniously */