summaryrefslogtreecommitdiff
path: root/drivers/net/phy
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2016-03-21 09:02:31 (GMT)
committerDavid S. Miller <davem@davemloft.net>2016-03-21 15:30:01 (GMT)
commit227f33beab746aeec4ef3305bd17b1d374df09e7 (patch)
tree41f1b2a258a2b98ff9ad5f34ba5dca9e28867cbd /drivers/net/phy
parentabc34d753ee013a62595c2f7e9260e173dd083c6 (diff)
downloadlinux-227f33beab746aeec4ef3305bd17b1d374df09e7.tar.xz
mdio-sun4i: oops in error handling in probe
We could end up dereferencing an error pointer when we call regulator_disable(). Fixes: 4bdcb1dd9feb ('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>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r--drivers/net/phy/mdio-sun4i.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/net/phy/mdio-sun4i.c b/drivers/net/phy/mdio-sun4i.c
index f70522c..1352965 100644
--- a/drivers/net/phy/mdio-sun4i.c
+++ b/drivers/net/phy/mdio-sun4i.c
@@ -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;