]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drivers: net: qlcnic: Fix potential memory leak in qlcnic_sriov_init()
authorYuan Can <yuancan@huawei.com>
Wed, 7 Dec 2022 08:54:10 +0000 (08:54 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jan 2023 11:07:21 +0000 (12:07 +0100)
[ Upstream commit 01de1123322e4fe1bbd0fcdf0982511b55519c03 ]

If vp alloc failed in qlcnic_sriov_init(), all previously allocated vp
needs to be freed.

Fixes: f197a7aa6288 ("qlcnic: VF-PF communication channel implementation")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c

index 44caa7c2077ec921e448c22c69c9eb31e205cf3c..d89d9247b7b9cf9fbe02538de6d60f90ba3ed44e 100644 (file)
@@ -222,6 +222,8 @@ int qlcnic_sriov_init(struct qlcnic_adapter *adapter, int num_vfs)
        return 0;
 
 qlcnic_destroy_async_wq:
+       while (i--)
+               kfree(sriov->vf_info[i].vp);
        destroy_workqueue(bc->bc_async_wq);
 
 qlcnic_destroy_trans_wq: