* [PATCH] net: stmmac: fix a broken u32 less than zero check
@ 2017-06-06 13:10 Colin King
2017-06-06 20:27 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2017-06-06 13:10 UTC (permalink / raw)
To: Giuseppe Cavallaro, Alexandre Torgue, netdev
Cc: kernel-janitors, linux-kernel
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: stmmac: fix a broken u32 less than zero check
2017-06-06 13:10 [PATCH] net: stmmac: fix a broken u32 less than zero check Colin King
@ 2017-06-06 20:27 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-06-06 20:27 UTC (permalink / raw)
To: colin.king
Cc: peppe.cavallaro, alexandre.torgue, netdev, kernel-janitors,
linux-kernel
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-06 20:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-06 13:10 [PATCH] net: stmmac: fix a broken u32 less than zero check Colin King
2017-06-06 20:27 ` 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).