linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] enetc: Fix an off by one in enetc_setup_tc_txtime()
@ 2020-01-07 13:11 Dan Carpenter
  2020-01-07 21:47 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2020-01-07 13:11 UTC (permalink / raw)
  To: Claudiu Manoil, Po Liu
  Cc: David S. Miller, netdev, linux-kernel, kernel-janitors

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>
---
 drivers/net/ethernet/freescale/enetc/enetc_qos.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c
index e910aaf0f5ec..00382b7c5bd8 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c
@@ -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 */
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] enetc: Fix an off by one in enetc_setup_tc_txtime()
  2020-01-07 13:11 [PATCH net-next] enetc: Fix an off by one in enetc_setup_tc_txtime() Dan Carpenter
@ 2020-01-07 21:47 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-01-07 21:47 UTC (permalink / raw)
  To: dan.carpenter
  Cc: claudiu.manoil, po.liu, netdev, linux-kernel, kernel-janitors

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Tue, 7 Jan 2020 16:11:43 +0300

> 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>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-07 21:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07 13:11 [PATCH net-next] enetc: Fix an off by one in enetc_setup_tc_txtime() Dan Carpenter
2020-01-07 21:47 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).