]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net: ethernet: arc: Fix a potential memory leak if an optional regulator is deferred
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 18 Mar 2018 22:59:36 +0000 (23:59 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 20 Mar 2018 16:06:23 +0000 (12:06 -0400)
If the optional regulator is deferred, we must release some resources.
They will be re-allocated when the probe function will be called again.

Fixes: 6eacf31139bf ("ethernet: arc: Add support for Rockchip SoC layer device tree bindings")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/arc/emac_rockchip.c

index 16f9bee992fedfab2069a2324c38fd4a5f142c93..0f65768026072ae7ded390fef283269f180f6e24 100644 (file)
@@ -169,8 +169,10 @@ static int emac_rockchip_probe(struct platform_device *pdev)
        /* Optional regulator for PHY */
        priv->regulator = devm_regulator_get_optional(dev, "phy");
        if (IS_ERR(priv->regulator)) {
-               if (PTR_ERR(priv->regulator) == -EPROBE_DEFER)
-                       return -EPROBE_DEFER;
+               if (PTR_ERR(priv->regulator) == -EPROBE_DEFER) {
+                       err = -EPROBE_DEFER;
+                       goto out_clk_disable;
+               }
                dev_err(dev, "no regulator found\n");
                priv->regulator = NULL;
        }