diff mbox series

[net] drivers: net: qlcnic: Fix potential memory leak in qlcnic_sriov_init()

Message ID 20221206103031.20609-1-yuancan@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net] drivers: net: qlcnic: Fix potential memory leak in qlcnic_sriov_init() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yuan Can Dec. 6, 2022, 10:30 a.m. UTC
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>
---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Leon Romanovsky Dec. 7, 2022, 7:56 a.m. UTC | #1
On Tue, Dec 06, 2022 at 10:30:31AM +0000, Yuan Can wrote:
> 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>
> ---
>  drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
> index 9282321c2e7f..d0470c62e1b2 100644
> --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
> +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
> @@ -222,6 +222,8 @@ int qlcnic_sriov_init(struct qlcnic_adapter *adapter, int num_vfs)
>  
>  qlcnic_destroy_async_wq:
>  	destroy_workqueue(bc->bc_async_wq);
> +	while (i--)
> +		kfree(sriov->vf_info[i].vp);

These lines should be before destroy_workqueue(bc->bc_async_wq);

Thanks

>  
>  qlcnic_destroy_trans_wq:
>  	destroy_workqueue(bc->bc_trans_wq);
> -- 
> 2.17.1
>
Yuan Can Dec. 7, 2022, 8:56 a.m. UTC | #2
在 2022/12/7 15:56, Leon Romanovsky 写道:
> On Tue, Dec 06, 2022 at 10:30:31AM +0000, Yuan Can wrote:
>> 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>
>> ---
>>   drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
>> index 9282321c2e7f..d0470c62e1b2 100644
>> --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
>> +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
>> @@ -222,6 +222,8 @@ int qlcnic_sriov_init(struct qlcnic_adapter *adapter, int num_vfs)
>>   
>>   qlcnic_destroy_async_wq:
>>   	destroy_workqueue(bc->bc_async_wq);
>> +	while (i--)
>> +		kfree(sriov->vf_info[i].vp);
> These lines should be before destroy_workqueue(bc->bc_async_wq);
Ok, thanks for the review!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
index 9282321c2e7f..d0470c62e1b2 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
@@ -222,6 +222,8 @@  int qlcnic_sriov_init(struct qlcnic_adapter *adapter, int num_vfs)
 
 qlcnic_destroy_async_wq:
 	destroy_workqueue(bc->bc_async_wq);
+	while (i--)
+		kfree(sriov->vf_info[i].vp);
 
 qlcnic_destroy_trans_wq:
 	destroy_workqueue(bc->bc_trans_wq);