821568
From b9b6752e5fd333fb88023cb5de4c1e6c0ce9d4e2 Mon Sep 17 00:00:00 2001
821568
From: Yuan Can <yuancan@huawei.com>
821568
Date: Wed, 7 Dec 2022 08:54:10 +0000
821568
Subject: [PATCH 1/3] drivers: net: qlcnic: Fix potential memory leak in
821568
 qlcnic_sriov_init()
821568
Patch-mainline: v6.2-rc1
821568
Git-commit: 01de1123322e4fe1bbd0fcdf0982511b55519c03
821568
References: jsc#PED-1523
821568
821568
If vp alloc failed in qlcnic_sriov_init(), all previously allocated vp
821568
needs to be freed.
821568
821568
Fixes: f197a7aa6288 ("qlcnic: VF-PF communication channel implementation")
821568
Signed-off-by: Yuan Can <yuancan@huawei.com>
821568
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
821568
Signed-off-by: David S. Miller <davem@davemloft.net>
821568
Signed-off-by: Denis Kirjanov <denis.kirjanov@suse.com>
821568
---
821568
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 2 ++
821568
 1 file changed, 2 insertions(+)
821568
821568
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
821568
index 9282321c2e7f..f9dd50152b1e 100644
821568
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
821568
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
821568
@@ -221,6 +221,8 @@ int qlcnic_sriov_init(struct qlcnic_adapter *adapter, int num_vfs)
821568
 	return 0;
821568
 
821568
 qlcnic_destroy_async_wq:
821568
+	while (i--)
821568
+		kfree(sriov->vf_info[i].vp);
821568
 	destroy_workqueue(bc->bc_async_wq);
821568
 
821568
 qlcnic_destroy_trans_wq:
821568
-- 
821568
2.16.4
821568