Commit 58e06d05 authored by Dan Carpenter's avatar Dan Carpenter Committed by Paolo Abeni

net: stmmac: clean up impossible condition

This code works but it has a static checker warning:

    drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:1687 init_dma_rx_desc_rings()
    warn: always true condition '(queue >= 0) => (0-u32max >= 0)'

Obviously, it makes no sense to check if an unsigned int is >= 0.  What
prevents this code from being a forever loop is that later there is a
separate check for if (queue == 0).

The "queue" variable is less than MTL_MAX_RX_QUEUES (8) so it can easily
fit in an int type.  Any larger value for "queue" would lead to an array
overflow when we assign "rx_q = &priv->rx_queue[queue]".

Fixes: de0b90e5 ("net: stmmac: rearrange RX and TX desc init into per-queue basis")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20220316083744.GB30941@kiliSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 435fe1c0
...@@ -1668,7 +1668,7 @@ static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags) ...@@ -1668,7 +1668,7 @@ static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags)
{ {
struct stmmac_priv *priv = netdev_priv(dev); struct stmmac_priv *priv = netdev_priv(dev);
u32 rx_count = priv->plat->rx_queues_to_use; u32 rx_count = priv->plat->rx_queues_to_use;
u32 queue; int queue;
int ret; int ret;
/* RX INITIALIZATION */ /* RX INITIALIZATION */
...@@ -1695,9 +1695,6 @@ static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags) ...@@ -1695,9 +1695,6 @@ static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags)
rx_q->buf_alloc_num = 0; rx_q->buf_alloc_num = 0;
rx_q->xsk_pool = NULL; rx_q->xsk_pool = NULL;
if (queue == 0)
break;
queue--; queue--;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment