]> Git Repo - linux.git/commitdiff
net: sfp: fix memory leak in sfp_probe()
authorJianglei Nie <[email protected]>
Wed, 29 Jun 2022 07:55:50 +0000 (15:55 +0800)
committerPaolo Abeni <[email protected]>
Thu, 30 Jun 2022 09:38:16 +0000 (11:38 +0200)
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 <[email protected]>
Reviewed-by: Russell King (Oracle) <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
drivers/net/phy/sfp.c

index 9a5d5a10560fb135d5b7a547795dfcdce6e94377..e7b0e12cc75bf3825ebf8d2044f6d6f92d95bf13 100644 (file)
@@ -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;
 
This page took 0.064136 seconds and 4 git commands to generate.