netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] octeontx2-vf: Add missing free for alloc_percpu
@ 2023-03-17  6:43 Jiasheng Jiang
  2023-03-17  8:18 ` Michal Swiatkowski
  2023-03-21  5:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Jiasheng Jiang @ 2023-03-17  6:43 UTC (permalink / raw)
  To: kuba
  Cc: sgoutham, gakula, sbhatta, hkelam, davem, edumazet, pabeni,
	richardcochran, netdev, linux-kernel, Jiasheng Jiang,
	Michal Swiatkowski

Add the free_percpu for the allocated "vf->hw.lmt_info" in order to avoid
memory leak, same as the "pf->hw.lmt_info" in
`drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c`.

Fixes: 5c0512072f65 ("octeontx2-pf: cn10k: Use runtime allocated LMTLINE region")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Acked-by: Geethasowjanya Akula <gakula@marvell.com>
---
Changelog:

v1 -> v2:

1. Remove the if () checks.
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
index 7f8ffbf79cf7..ab126f8706c7 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
@@ -709,6 +709,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 err_ptp_destroy:
 	otx2_ptp_destroy(vf);
 err_detach_rsrc:
+	free_percpu(vf->hw.lmt_info);
 	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
 		qmem_free(vf->dev, vf->dync_lmt);
 	otx2_detach_resources(&vf->mbox);
@@ -762,6 +763,7 @@ static void otx2vf_remove(struct pci_dev *pdev)
 	otx2_shutdown_tc(vf);
 	otx2vf_disable_mbox_intr(vf);
 	otx2_detach_resources(&vf->mbox);
+	free_percpu(vf->hw.lmt_info);
 	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
 		qmem_free(vf->dev, vf->dync_lmt);
 	otx2vf_vfaf_mbox_destroy(vf);
-- 
2.25.1


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

* Re: [PATCH v2] octeontx2-vf: Add missing free for alloc_percpu
  2023-03-17  6:43 [PATCH v2] octeontx2-vf: Add missing free for alloc_percpu Jiasheng Jiang
@ 2023-03-17  8:18 ` Michal Swiatkowski
  2023-03-17  9:00   ` Michal Swiatkowski
  2023-03-21  5:10 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Michal Swiatkowski @ 2023-03-17  8:18 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: kuba, sgoutham, gakula, sbhatta, hkelam, davem, edumazet, pabeni,
	richardcochran, netdev, linux-kernel

On Fri, Mar 17, 2023 at 02:43:37PM +0800, Jiasheng Jiang wrote:
> Add the free_percpu for the allocated "vf->hw.lmt_info" in order to avoid
> memory leak, same as the "pf->hw.lmt_info" in
> `drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c`.
> 
> Fixes: 5c0512072f65 ("octeontx2-pf: cn10k: Use runtime allocated LMTLINE region")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Acked-by: Geethasowjanya Akula <gakula@marvell.com>
> ---
> Changelog:
> 
> v1 -> v2:
> 
> 1. Remove the if () checks.
Hi,

Did You change that because of my comments? I am not sure it is correct.
I meant moving these two ifs to new function, because they are called
two times. It will be easier to do changes in the future.

void cn10k_lmtst_deinit(struct otx2_nic *pfvf)
{
	if (vf->hw.lmt_info)
		free_percpu(vf->hw.lmt_info);
	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
		qmem_free(vf->dev, vf->dync_lmt);
}

Thanks,
Michal

> ---
>  drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
> index 7f8ffbf79cf7..ab126f8706c7 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
> @@ -709,6 +709,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  err_ptp_destroy:
>  	otx2_ptp_destroy(vf);
>  err_detach_rsrc:
> +	free_percpu(vf->hw.lmt_info);
>  	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
>  		qmem_free(vf->dev, vf->dync_lmt);
>  	otx2_detach_resources(&vf->mbox);
> @@ -762,6 +763,7 @@ static void otx2vf_remove(struct pci_dev *pdev)
>  	otx2_shutdown_tc(vf);
>  	otx2vf_disable_mbox_intr(vf);
>  	otx2_detach_resources(&vf->mbox);
> +	free_percpu(vf->hw.lmt_info);
>  	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
>  		qmem_free(vf->dev, vf->dync_lmt);
>  	otx2vf_vfaf_mbox_destroy(vf);
> -- 
> 2.25.1
> 

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

* Re: [PATCH v2] octeontx2-vf: Add missing free for alloc_percpu
  2023-03-17  8:18 ` Michal Swiatkowski
@ 2023-03-17  9:00   ` Michal Swiatkowski
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Swiatkowski @ 2023-03-17  9:00 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: kuba, sgoutham, gakula, sbhatta, hkelam, davem, edumazet, pabeni,
	richardcochran, netdev, linux-kernel

On Fri, Mar 17, 2023 at 09:18:06AM +0100, Michal Swiatkowski wrote:
> On Fri, Mar 17, 2023 at 02:43:37PM +0800, Jiasheng Jiang wrote:
> > Add the free_percpu for the allocated "vf->hw.lmt_info" in order to avoid
> > memory leak, same as the "pf->hw.lmt_info" in
> > `drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c`.
> > 
> > Fixes: 5c0512072f65 ("octeontx2-pf: cn10k: Use runtime allocated LMTLINE region")
> > Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> > Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> > Acked-by: Geethasowjanya Akula <gakula@marvell.com>
> > ---
> > Changelog:
> > 
> > v1 -> v2:
> > 
> > 1. Remove the if () checks.
> Hi,
> 
> Did You change that because of my comments? I am not sure it is correct.
> I meant moving these two ifs to new function, because they are called
> two times. It will be easier to do changes in the future.
> 
> void cn10k_lmtst_deinit(struct otx2_nic *pfvf)
> {
> 	if (vf->hw.lmt_info)
> 		free_percpu(vf->hw.lmt_info);
> 	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
> 		qmem_free(vf->dev, vf->dync_lmt);
> }
> 
> Thanks,
> Michal
> 

Sorry, ignore, I just saw a message that free_percpu handle NULL
correctly.

> > ---
> >  drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
> > index 7f8ffbf79cf7..ab126f8706c7 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
> > @@ -709,6 +709,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> >  err_ptp_destroy:
> >  	otx2_ptp_destroy(vf);
> >  err_detach_rsrc:
> > +	free_percpu(vf->hw.lmt_info);
> >  	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
> >  		qmem_free(vf->dev, vf->dync_lmt);
> >  	otx2_detach_resources(&vf->mbox);
> > @@ -762,6 +763,7 @@ static void otx2vf_remove(struct pci_dev *pdev)
> >  	otx2_shutdown_tc(vf);
> >  	otx2vf_disable_mbox_intr(vf);
> >  	otx2_detach_resources(&vf->mbox);
> > +	free_percpu(vf->hw.lmt_info);
> >  	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
> >  		qmem_free(vf->dev, vf->dync_lmt);
> >  	otx2vf_vfaf_mbox_destroy(vf);
> > -- 
> > 2.25.1
> > 

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

* Re: [PATCH v2] octeontx2-vf: Add missing free for alloc_percpu
  2023-03-17  6:43 [PATCH v2] octeontx2-vf: Add missing free for alloc_percpu Jiasheng Jiang
  2023-03-17  8:18 ` Michal Swiatkowski
@ 2023-03-21  5:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-03-21  5:10 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: kuba, sgoutham, gakula, sbhatta, hkelam, davem, edumazet, pabeni,
	richardcochran, netdev, linux-kernel, michal.swiatkowski

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 17 Mar 2023 14:43:37 +0800 you wrote:
> Add the free_percpu for the allocated "vf->hw.lmt_info" in order to avoid
> memory leak, same as the "pf->hw.lmt_info" in
> `drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c`.
> 
> Fixes: 5c0512072f65 ("octeontx2-pf: cn10k: Use runtime allocated LMTLINE region")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Acked-by: Geethasowjanya Akula <gakula@marvell.com>
> 
> [...]

Here is the summary with links:
  - [v2] octeontx2-vf: Add missing free for alloc_percpu
    https://git.kernel.org/netdev/net/c/f038f3917baf

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-03-21  5:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-17  6:43 [PATCH v2] octeontx2-vf: Add missing free for alloc_percpu Jiasheng Jiang
2023-03-17  8:18 ` Michal Swiatkowski
2023-03-17  9:00   ` Michal Swiatkowski
2023-03-21  5:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).