summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnirudh Rayabharam <mail@anirudhrb.com>2021-05-03 13:56:48 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-05-26 11:27:33 +0200
commitc88c3326f23474997d4eb958459d4762c87b5df6 (patch)
tree1208840d204c3de9116b804b13c1e9840e128a1f
parent378041c9c4aa331ce7fad8343d62778f4ea99f12 (diff)
downloadlinux-stable-c88c3326f23474997d4eb958459d4762c87b5df6.tar.gz
linux-stable-c88c3326f23474997d4eb958459d4762c87b5df6.tar.bz2
linux-stable-c88c3326f23474997d4eb958459d4762c87b5df6.zip
net: stmicro: handle clk_prepare() failure during init
commit 0c32a96d000f260b5ebfabb4145a86ae1cd71847 upstream. In case clk_prepare() fails, capture and propagate the error code up the stack. If regulator_enable() was called earlier, properly unwind it by calling regulator_disable(). Signed-off-by: Anirudh Rayabharam <mail@anirudhrb.com> Cc: David S. Miller <davem@davemloft.net> Cc: stable <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20210503115736.2104747-22-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
index 92e9d8c74e02..d9cbc5dcf3ec 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
@@ -39,7 +39,7 @@ struct sunxi_priv_data {
static int sun7i_gmac_init(struct platform_device *pdev, void *priv)
{
struct sunxi_priv_data *gmac = priv;
- int ret;
+ int ret = 0;
if (gmac->regulator) {
ret = regulator_enable(gmac->regulator);
@@ -59,10 +59,12 @@ static int sun7i_gmac_init(struct platform_device *pdev, void *priv)
gmac->clk_enabled = 1;
} else {
clk_set_rate(gmac->tx_clk, SUN7I_GMAC_MII_RATE);
- clk_prepare(gmac->tx_clk);
+ ret = clk_prepare(gmac->tx_clk);
+ if (ret && gmac->regulator)
+ regulator_disable(gmac->regulator);
}
- return 0;
+ return ret;
}
static void sun7i_gmac_exit(struct platform_device *pdev, void *priv)