mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next] pds_core: fix memory leak in pdsc_debugfs_add_qcq()
@ 2025-04-09  5:44 Abdun Nihaal
  2025-04-09  6:44 ` Michal Swiatkowski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Abdun Nihaal @ 2025-04-09  5:44 UTC (permalink / raw)
  To: shannon.nelson
  Cc: Abdun Nihaal, brett.creeley, andrew+netdev, davem, edumazet,
	kuba, pabeni, netdev, linux-kernel

The memory allocated for intr_ctrl_regset, which is passed to
debugfs_create_regset32() may not be cleaned up when the driver is
removed. Fix that by using device managed allocation for it.

Fixes: 45d76f492938 ("pds_core: set up device and adminq")
Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
---
 drivers/net/ethernet/amd/pds_core/debugfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/amd/pds_core/debugfs.c b/drivers/net/ethernet/amd/pds_core/debugfs.c
index ac37a4e738ae..04c5e3abd8d7 100644
--- a/drivers/net/ethernet/amd/pds_core/debugfs.c
+++ b/drivers/net/ethernet/amd/pds_core/debugfs.c
@@ -154,8 +154,9 @@ void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq)
 		debugfs_create_u32("index", 0400, intr_dentry, &intr->index);
 		debugfs_create_u32("vector", 0400, intr_dentry, &intr->vector);
 
-		intr_ctrl_regset = kzalloc(sizeof(*intr_ctrl_regset),
-					   GFP_KERNEL);
+		intr_ctrl_regset = devm_kzalloc(pdsc->dev,
+						sizeof(*intr_ctrl_regset),
+						GFP_KERNEL);
 		if (!intr_ctrl_regset)
 			return;
 		intr_ctrl_regset->regs = intr_ctrl_regs;
-- 
2.47.2


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

* Re: [PATCH net-next] pds_core: fix memory leak in pdsc_debugfs_add_qcq()
  2025-04-09  5:44 [PATCH net-next] pds_core: fix memory leak in pdsc_debugfs_add_qcq() Abdun Nihaal
@ 2025-04-09  6:44 ` Michal Swiatkowski
  2025-04-09 17:18 ` Nelson, Shannon
  2025-04-12  1:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Michal Swiatkowski @ 2025-04-09  6:44 UTC (permalink / raw)
  To: Abdun Nihaal
  Cc: shannon.nelson, brett.creeley, andrew+netdev, davem, edumazet,
	kuba, pabeni, netdev, linux-kernel

On Wed, Apr 09, 2025 at 11:14:48AM +0530, Abdun Nihaal wrote:
> The memory allocated for intr_ctrl_regset, which is passed to
> debugfs_create_regset32() may not be cleaned up when the driver is
> removed. Fix that by using device managed allocation for it.
> 
> Fixes: 45d76f492938 ("pds_core: set up device and adminq")
> Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
> ---
>  drivers/net/ethernet/amd/pds_core/debugfs.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/amd/pds_core/debugfs.c b/drivers/net/ethernet/amd/pds_core/debugfs.c
> index ac37a4e738ae..04c5e3abd8d7 100644
> --- a/drivers/net/ethernet/amd/pds_core/debugfs.c
> +++ b/drivers/net/ethernet/amd/pds_core/debugfs.c
> @@ -154,8 +154,9 @@ void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq)
>  		debugfs_create_u32("index", 0400, intr_dentry, &intr->index);
>  		debugfs_create_u32("vector", 0400, intr_dentry, &intr->vector);
>  
> -		intr_ctrl_regset = kzalloc(sizeof(*intr_ctrl_regset),
> -					   GFP_KERNEL);
> +		intr_ctrl_regset = devm_kzalloc(pdsc->dev,
> +						sizeof(*intr_ctrl_regset),
> +						GFP_KERNEL);
>  		if (!intr_ctrl_regset)
>  			return;
>  		intr_ctrl_regset->regs = intr_ctrl_regs;

In ionic driver it is also devm_ version, thanks for catching that.
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>

For future submission remember to set correct target (net instead of
net-next as it is a fix)

Thanks,
Michal

> -- 
> 2.47.2

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

* Re: [PATCH net-next] pds_core: fix memory leak in pdsc_debugfs_add_qcq()
  2025-04-09  5:44 [PATCH net-next] pds_core: fix memory leak in pdsc_debugfs_add_qcq() Abdun Nihaal
  2025-04-09  6:44 ` Michal Swiatkowski
@ 2025-04-09 17:18 ` Nelson, Shannon
  2025-04-12  1:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Nelson, Shannon @ 2025-04-09 17:18 UTC (permalink / raw)
  To: Abdun Nihaal
  Cc: brett.creeley, andrew+netdev, davem, edumazet, kuba, pabeni,
	netdev, linux-kernel

On 4/8/2025 10:44 PM, Abdun Nihaal wrote:
> 
> The memory allocated for intr_ctrl_regset, which is passed to
> debugfs_create_regset32() may not be cleaned up when the driver is
> removed. Fix that by using device managed allocation for it.
> 
> Fixes: 45d76f492938 ("pds_core: set up device and adminq")
> Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>

Thanks!

Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>

> ---
>   drivers/net/ethernet/amd/pds_core/debugfs.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/amd/pds_core/debugfs.c b/drivers/net/ethernet/amd/pds_core/debugfs.c
> index ac37a4e738ae..04c5e3abd8d7 100644
> --- a/drivers/net/ethernet/amd/pds_core/debugfs.c
> +++ b/drivers/net/ethernet/amd/pds_core/debugfs.c
> @@ -154,8 +154,9 @@ void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq)
>                  debugfs_create_u32("index", 0400, intr_dentry, &intr->index);
>                  debugfs_create_u32("vector", 0400, intr_dentry, &intr->vector);
> 
> -               intr_ctrl_regset = kzalloc(sizeof(*intr_ctrl_regset),
> -                                          GFP_KERNEL);
> +               intr_ctrl_regset = devm_kzalloc(pdsc->dev,
> +                                               sizeof(*intr_ctrl_regset),
> +                                               GFP_KERNEL);
>                  if (!intr_ctrl_regset)
>                          return;
>                  intr_ctrl_regset->regs = intr_ctrl_regs;
> --
> 2.47.2
> 


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

* Re: [PATCH net-next] pds_core: fix memory leak in pdsc_debugfs_add_qcq()
  2025-04-09  5:44 [PATCH net-next] pds_core: fix memory leak in pdsc_debugfs_add_qcq() Abdun Nihaal
  2025-04-09  6:44 ` Michal Swiatkowski
  2025-04-09 17:18 ` Nelson, Shannon
@ 2025-04-12  1:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-12  1:40 UTC (permalink / raw)
  To: Abdun Nihaal
  Cc: shannon.nelson, brett.creeley, andrew+netdev, davem, edumazet,
	kuba, pabeni, netdev, linux-kernel

Hello:

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

On Wed,  9 Apr 2025 11:14:48 +0530 you wrote:
> The memory allocated for intr_ctrl_regset, which is passed to
> debugfs_create_regset32() may not be cleaned up when the driver is
> removed. Fix that by using device managed allocation for it.
> 
> Fixes: 45d76f492938 ("pds_core: set up device and adminq")
> Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
> 
> [...]

Here is the summary with links:
  - [net-next] pds_core: fix memory leak in pdsc_debugfs_add_qcq()
    https://git.kernel.org/netdev/net/c/8b82f656826c

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:[~2025-04-12  1:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-09  5:44 [PATCH net-next] pds_core: fix memory leak in pdsc_debugfs_add_qcq() Abdun Nihaal
2025-04-09  6:44 ` Michal Swiatkowski
2025-04-09 17:18 ` Nelson, Shannon
2025-04-12  1:40 ` 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

Powered by JetHome