mdio-sun4i: oops in error handling in probe

We could end up dereferencing an error pointer when we call
regulator_disable().

Fixes: 4bdcb1dd9f ('net: Add MDIO bus driver for the Allwinner EMAC')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Dan Carpenter 2016-03-21 12:02:31 +03:00 committed by David S. Miller
parent abc34d753e
commit 227f33beab
1 changed files with 3 additions and 1 deletions

View File

@ -122,6 +122,7 @@ static int sun4i_mdio_probe(struct platform_device *pdev)
return -EPROBE_DEFER;
dev_info(&pdev->dev, "no regulator found\n");
data->regulator = NULL;
} else {
ret = regulator_enable(data->regulator);
if (ret)
@ -137,7 +138,8 @@ static int sun4i_mdio_probe(struct platform_device *pdev)
return 0;
err_out_disable_regulator:
regulator_disable(data->regulator);
if (data->regulator)
regulator_disable(data->regulator);
err_out_free_mdiobus:
mdiobus_free(bus);
return ret;