All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v3] net: sfp: fix memory leak in sfp_probe()
@ 2022-06-29  7:55 Jianglei Nie
  2022-06-29  9:43 ` Russell King (Oracle)
  2022-06-30 10:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jianglei Nie @ 2022-06-29  7:55 UTC (permalink / raw)
  To: linux, andrew, hkallweit1, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Jianglei Nie

sfp_probe() allocates a memory chunk from sfp with sfp_alloc(). When
devm_add_action() fails, sfp is not freed, which leads to a memory leak.

We should use devm_add_action_or_reset() instead of devm_add_action().

Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
---
 drivers/net/phy/sfp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 9a5d5a10560f..e7b0e12cc75b 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -2516,7 +2516,7 @@ static int sfp_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, sfp);
 
-	err = devm_add_action(sfp->dev, sfp_cleanup, sfp);
+	err = devm_add_action_or_reset(sfp->dev, sfp_cleanup, sfp);
 	if (err < 0)
 		return err;
 
-- 
2.25.1


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

* Re: [PATCH net v3] net: sfp: fix memory leak in sfp_probe()
  2022-06-29  7:55 [PATCH net v3] net: sfp: fix memory leak in sfp_probe() Jianglei Nie
@ 2022-06-29  9:43 ` Russell King (Oracle)
  2022-06-30 10:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Russell King (Oracle) @ 2022-06-29  9:43 UTC (permalink / raw)
  To: Jianglei Nie
  Cc: andrew, hkallweit1, davem, edumazet, kuba, pabeni, netdev, linux-kernel

On Wed, Jun 29, 2022 at 03:55:50PM +0800, Jianglei Nie wrote:
> sfp_probe() allocates a memory chunk from sfp with sfp_alloc(). When
> devm_add_action() fails, sfp is not freed, which leads to a memory leak.
> 
> We should use devm_add_action_or_reset() instead of devm_add_action().
> 
> Signed-off-by: Jianglei Nie <niejianglei2021@163.com>

Thanks!

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH net v3] net: sfp: fix memory leak in sfp_probe()
  2022-06-29  7:55 [PATCH net v3] net: sfp: fix memory leak in sfp_probe() Jianglei Nie
  2022-06-29  9:43 ` Russell King (Oracle)
@ 2022-06-30 10:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-06-30 10:00 UTC (permalink / raw)
  To: Jianglei Nie
  Cc: linux, andrew, hkallweit1, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

Hello:

This patch was applied to netdev/net.git (master)
by Paolo Abeni <pabeni@redhat.com>:

On Wed, 29 Jun 2022 15:55:50 +0800 you wrote:
> sfp_probe() allocates a memory chunk from sfp with sfp_alloc(). When
> devm_add_action() fails, sfp is not freed, which leads to a memory leak.
> 
> We should use devm_add_action_or_reset() instead of devm_add_action().
> 
> Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
> 
> [...]

Here is the summary with links:
  - [net,v3] net: sfp: fix memory leak in sfp_probe()
    https://git.kernel.org/netdev/net/c/0a18d802d65c

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] 3+ messages in thread

end of thread, other threads:[~2022-06-30 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-29  7:55 [PATCH net v3] net: sfp: fix memory leak in sfp_probe() Jianglei Nie
2022-06-29  9:43 ` Russell King (Oracle)
2022-06-30 10:00 ` patchwork-bot+netdevbpf

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.