All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] drivers: net: qlcnic: Fix potential memory leak in qlcnic_sriov_init()
@ 2022-12-06 10:30 Yuan Can
  2022-12-07  7:56 ` Leon Romanovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Yuan Can @ 2022-12-06 10:30 UTC (permalink / raw)
  To: shshaikh, manishc, GR-Linux-NIC-Dev, davem, edumazet, kuba,
	pabeni, sucheta.chakraborty, rajesh.borundia, netdev
  Cc: yuancan

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);
 
 qlcnic_destroy_trans_wq:
 	destroy_workqueue(bc->bc_trans_wq);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] drivers: net: qlcnic: Fix potential memory leak in qlcnic_sriov_init()
  2022-12-06 10:30 [PATCH net] drivers: net: qlcnic: Fix potential memory leak in qlcnic_sriov_init() Yuan Can
@ 2022-12-07  7:56 ` Leon Romanovsky
  2022-12-07  8:56   ` Yuan Can
  0 siblings, 1 reply; 3+ messages in thread
From: Leon Romanovsky @ 2022-12-07  7:56 UTC (permalink / raw)
  To: Yuan Can
  Cc: shshaikh, manishc, GR-Linux-NIC-Dev, davem, edumazet, kuba,
	pabeni, sucheta.chakraborty, rajesh.borundia, netdev

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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] drivers: net: qlcnic: Fix potential memory leak in qlcnic_sriov_init()
  2022-12-07  7:56 ` Leon Romanovsky
@ 2022-12-07  8:56   ` Yuan Can
  0 siblings, 0 replies; 3+ messages in thread
From: Yuan Can @ 2022-12-07  8:56 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: shshaikh, manishc, GR-Linux-NIC-Dev, davem, edumazet, kuba,
	pabeni, sucheta.chakraborty, rajesh.borundia, netdev


在 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!

-- 
Best regards,
Yuan Can


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-07  8:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-06 10:30 [PATCH net] drivers: net: qlcnic: Fix potential memory leak in qlcnic_sriov_init() Yuan Can
2022-12-07  7:56 ` Leon Romanovsky
2022-12-07  8:56   ` Yuan Can

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.