Skip to content

Commit 0a18d80

Browse files
Jianglei NiePaolo Abeni
authored andcommitted
net: sfp: fix memory leak in sfp_probe()
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> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Link: https://lore.kernel.org/r/20220629075550.2152003-1-niejianglei2021@163.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 665030f commit 0a18d80

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/net/phy/sfp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2516,7 +2516,7 @@ static int sfp_probe(struct platform_device *pdev)
25162516

25172517
platform_set_drvdata(pdev, sfp);
25182518

2519-
err = devm_add_action(sfp->dev, sfp_cleanup, sfp);
2519+
err = devm_add_action_or_reset(sfp->dev, sfp_cleanup, sfp);
25202520
if (err < 0)
25212521
return err;
25222522

0 commit comments

Comments
 (0)