diff mbox series

[2/7,Focal/linux-azure] net: mana: Fix a memory leak in an error handling path in 'mana_create_txq()'

Message ID 20211021122400.10390-3-tim.gardner@canonical.com
State New
Headers show
Series Update Microsoft MANA to 5.15-rc6 | expand

Commit Message

Tim Gardner Oct. 21, 2021, 12:23 p.m. UTC
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

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

If this test fails we must free some resources as in all the other error
handling paths of this function.

Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit b90788459cd6d140171b046f0b37fad341ade0a3)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 drivers/net/ethernet/microsoft/mana/mana_en.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 02aff16df27f0..8fdf0104c4155 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -1231,8 +1231,10 @@  static int mana_create_txq(struct mana_port_context *apc,
 
 		cq->gdma_id = cq->gdma_cq->id;
 
-		if (WARN_ON(cq->gdma_id >= gc->max_num_cqs))
-			return -EINVAL;
+		if (WARN_ON(cq->gdma_id >= gc->max_num_cqs)) {
+			err = -EINVAL;
+			goto out;
+		}
 
 		gc->cq_table[cq->gdma_id] = cq->gdma_cq;