Skip to content

Commit

Permalink
net: davicom: Fix regulator not turned off on failed probe
Browse files Browse the repository at this point in the history
commit ac88c53 upstream.

When the probe fails or requests to be defered, we must disable the
regulator that was previously enabled.

Fixes: 7994fe5 ("dm9000: Add regulator and reset support to dm9000")
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
pcercuei authored and gregkh committed Mar 17, 2021
1 parent 8eb43ff commit c32b8c0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions drivers/net/ethernet/davicom/dm9000.c
Expand Up @@ -1449,7 +1449,7 @@ dm9000_probe(struct platform_device *pdev)
if (ret) {
dev_err(dev, "failed to request reset gpio %d: %d\n",
reset_gpios, ret);
return -ENODEV;
goto out_regulator_disable;
}

/* According to manual PWRST# Low Period Min 1ms */
Expand All @@ -1461,8 +1461,10 @@ dm9000_probe(struct platform_device *pdev)

if (!pdata) {
pdata = dm9000_parse_dt(&pdev->dev);
if (IS_ERR(pdata))
return PTR_ERR(pdata);
if (IS_ERR(pdata)) {
ret = PTR_ERR(pdata);
goto out_regulator_disable;
}
}

/* Init network device */
Expand Down Expand Up @@ -1703,6 +1705,10 @@ dm9000_probe(struct platform_device *pdev)
dm9000_release_board(pdev, db);
free_netdev(ndev);

out_regulator_disable:
if (!IS_ERR(power))
regulator_disable(power);

return ret;
}

Expand Down

0 comments on commit c32b8c0

Please sign in to comment.