gve: Fix off by one in gve_tx_timeout()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 9 Nov 2021 11:47:36 +0000 (14:47 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 9 Nov 2021 13:58:46 +0000 (13:58 +0000)
The priv->ntfy_blocks[] has "priv->num_ntfy_blks" elements so this >
needs to be >= to prevent an off by one bug.  The priv->ntfy_blocks[]
array is allocated in gve_alloc_notify_blocks().

Fixes: 87a7f321bb6a ("gve: Recover from queue stall due to missed IRQ")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/google/gve/gve_main.c

index 6b02ef432eda6b6d0c372fe08c35c221552e1f76..59b66f679e46e896f122da9cee171ff301968735 100644 (file)
@@ -1137,7 +1137,7 @@ static void gve_tx_timeout(struct net_device *dev, unsigned int txqueue)
                goto reset;
 
        ntfy_idx = gve_tx_idx_to_ntfy(priv, txqueue);
-       if (ntfy_idx > priv->num_ntfy_blks)
+       if (ntfy_idx >= priv->num_ntfy_blks)
                goto reset;
 
        block = &priv->ntfy_blocks[ntfy_idx];