[PATCH 7/7][Focal/linux-azure] net: mana: Fix error handling in mana_create_rxq()

Tim Gardner tim.gardner at canonical.com
Thu Oct 21 12:23:41 UTC 2021


From: Haiyang Zhang <haiyangz at microsoft.com>

BugLink: https://bugs.launchpad.net/bugs/1947859

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 at microsoft.com>
Link: https://lore.kernel.org/r/1633698691-31721-1-git-send-email-haiyangz@microsoft.com
Signed-off-by: Jakub Kicinski <kuba at kernel.org>
(cherry picked from commit be0499369d6376e70b5b80bbced94c0c32d508b1)
Signed-off-by: Tim Gardner <tim.gardner at canonical.com>
---
 drivers/net/ethernet/microsoft/mana/mana_en.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index cc22ada9c085c..67662a46e788b 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -1478,8 +1478,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;
 
-- 
2.33.1




More information about the kernel-team mailing list