]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: mana: Fix error handling in mana_create_rxq()
authorHaiyang Zhang <haiyangz@microsoft.com>
Fri, 8 Oct 2021 13:11:31 +0000 (06:11 -0700)
committerJakub Kicinski <kuba@kernel.org>
Sat, 9 Oct 2021 00:00:04 +0000 (17:00 -0700)
Fix error handling in mana_create_rxq() when
cq->gdma_id >= gc->max_num_cqs.

Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)")
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Link: https://lore.kernel.org/r/1633698691-31721-1-git-send-email-haiyangz@microsoft.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/microsoft/mana/mana_en.c

index 1b21030308e57c6004c299eb6e76de5a822fd8d6..030ae89f3a337abb52568185b494c15945e309f5 100644 (file)
@@ -1477,8 +1477,10 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc,
        if (err)
                goto out;
 
-       if (cq->gdma_id >= gc->max_num_cqs)
+       if (WARN_ON(cq->gdma_id >= gc->max_num_cqs)) {
+               err = -EINVAL;
                goto out;
+       }
 
        gc->cq_table[cq->gdma_id] = cq->gdma_cq;