diff mbox series

[net-next] net: stmmac: fix missing unlock on error in stmmac_suspend()

Message ID 20210316074239.2010897-1-weiyongjun1@huawei.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: stmmac: fix missing unlock on error in stmmac_suspend() | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers fail 2 blamed authors not CCed: davem@davemloft.net andrew@lunn.ch; 2 maintainers not CCed: davem@davemloft.net andrew@lunn.ch
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Wei Yongjun March 16, 2021, 7:42 a.m. UTC
From: Wei Yongjun <weiyongjun1@huawei.com>

Add the missing unlock before return from function
stmmac_suspend() in the error handling case.

Fixes: 5ec55823438e ("net: stmmac: add clocks management for gmac driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Edmundo Carmona Antoranz March 16, 2021, 1:55 p.m. UTC | #1
On Tue, Mar 16, 2021 at 7:50 AM Edmundo Carmona Antoranz
<eantoranz@gmail.com> wrote:

> I think you can let it go and check ret after unlocking:
>
>                 /* Disable clock in case of PWM is off */
>                clk_disable_unprepare(priv->plat->clk_ptp_ref);
>                ret = pm_runtime_force_suspend(dev);
>        }
>        mutex_unlock(&priv->lock);
>        if (ret)
>                return ret;

Oh, I C. It would require ret to be set to 0 before starting to use
it, right? Maybe it's worth it?

>
>        priv->speed = SPEED_UNKNOWN;
>        return 0;
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a10704d8e3c6..d50df998d3aa 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5400,8 +5400,10 @@  int stmmac_suspend(struct device *dev)
 		/* Disable clock in case of PWM is off */
 		clk_disable_unprepare(priv->plat->clk_ptp_ref);
 		ret = pm_runtime_force_suspend(dev);
-		if (ret)
+		if (ret) {
+			mutex_unlock(&priv->lock);
 			return ret;
+		}
 	}
 	mutex_unlock(&priv->lock);