Commit 56c02902 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by David S. Miller

mdio-sun4i: Fix a memory leak

If the probing of the regulator is deferred, the memory allocated by
'mdiobus_alloc_size()' will be leaking.
It should be freed before the next call to 'sun4i_mdio_probe()' which will
reallocate it.

Fixes: 4bdcb1dd ("net: Add MDIO bus driver for the Allwinner EMAC")
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 46cd7503
...@@ -118,8 +118,10 @@ static int sun4i_mdio_probe(struct platform_device *pdev) ...@@ -118,8 +118,10 @@ static int sun4i_mdio_probe(struct platform_device *pdev)
data->regulator = devm_regulator_get(&pdev->dev, "phy"); data->regulator = devm_regulator_get(&pdev->dev, "phy");
if (IS_ERR(data->regulator)) { if (IS_ERR(data->regulator)) {
if (PTR_ERR(data->regulator) == -EPROBE_DEFER) if (PTR_ERR(data->regulator) == -EPROBE_DEFER) {
return -EPROBE_DEFER; ret = -EPROBE_DEFER;
goto err_out_free_mdiobus;
}
dev_info(&pdev->dev, "no regulator found\n"); dev_info(&pdev->dev, "no regulator found\n");
data->regulator = NULL; data->regulator = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment