]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
net: stmmac: fix a broken u32 less than zero check
authorColin Ian King <colin.king@canonical.com>
Tue, 6 Jun 2017 13:10:49 +0000 (14:10 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 6 Jun 2017 20:26:28 +0000 (16:26 -0400)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index dcbe4537ad99b2a1260f550bca777a30ee24deb1..12236daf7bb6d5358fdafe50e37227e19b95bc33 100644 (file)
@@ -1208,7 +1208,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)