Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1658759 > unrolled thread

[PATCH] net: stmmac: fix a broken u32 less than zero check

Started byColin King <colin.king@canonical.com>
First post2017-06-06 15:20 +0200
Last post2017-06-06 22:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net: stmmac: fix a broken u32 less than zero check Colin King <colin.king@canonical.com> - 2017-06-06 15:20 +0200
    Re: [PATCH] net: stmmac: fix a broken u32 less than zero check David Miller <davem@davemloft.net> - 2017-06-06 22:30 +0200

#1658759 — [PATCH] net: stmmac: fix a broken u32 less than zero check

FromColin King <colin.king@canonical.com>
Date2017-06-06 15:20 +0200
Subject[PATCH] net: stmmac: fix a broken u32 less than zero check
Message-ID<tPmyR-S4-7@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

The check that queue is less or equal to zero is always true
because queue is a u32; queue is decremented and will wrap around
and never go -ve. Fix this by making queue an int.

Detected by CoverityScan, CID#1428988 ("Unsigned compared against 0")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 68a188e74c54..05b1ec9194da 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1207,7 +1207,7 @@ static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags)
 	u32 rx_count = priv->plat->rx_queues_to_use;
 	unsigned int bfsize = 0;
 	int ret = -ENOMEM;
-	u32 queue;
+	int queue;
 	int i;
 
 	if (priv->hw->mode->set_16kib_bfsize)
-- 
2.11.0

[toc] | [next] | [standalone]


#1659174

FromDavid Miller <davem@davemloft.net>
Date2017-06-06 22:30 +0200
Message-ID<tPtgZ-5bW-1@gated-at.bofh.it>
In reply to#1658759
From: Colin King <colin.king@canonical.com>
Date: Tue,  6 Jun 2017 14:10:49 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> The check that queue is less or equal to zero is always true
> because queue is a u32; queue is decremented and will wrap around
> and never go -ve. Fix this by making queue an int.
> 
> Detected by CoverityScan, CID#1428988 ("Unsigned compared against 0")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied, thanks Colin.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web