Skip to content

Commit

Permalink
mdio-sun4i: Fix a memory leak
Browse files Browse the repository at this point in the history
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: 4bdcb1d ("net: Add MDIO bus driver for the Allwinner EMAC")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Christophe JAILLET authored and David S. Miller committed Jan 8, 2018
1 parent 46cd750 commit 56c0290
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/net/phy/mdio-sun4i.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ static int sun4i_mdio_probe(struct platform_device *pdev)

data->regulator = devm_regulator_get(&pdev->dev, "phy");
if (IS_ERR(data->regulator)) {
if (PTR_ERR(data->regulator) == -EPROBE_DEFER)
return -EPROBE_DEFER;
if (PTR_ERR(data->regulator) == -EPROBE_DEFER) {
ret = -EPROBE_DEFER;
goto err_out_free_mdiobus;
}

dev_info(&pdev->dev, "no regulator found\n");
data->regulator = NULL;
Expand Down

0 comments on commit 56c0290

Please sign in to comment.