Skip to contentSkip to conversation

net: stmmac: fix missing unlock on error in stmmac_suspend()

PATCH In review 'w00385741 2 participants 2 messages Mar 16, 2021 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore

'w00385741

author
#0 lore raw

PATCH 1/1 net: stmmac: fix missing unlock on error in stmmac_suspend()

From: Wei Yongjun <[email protected]>

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")
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -1
index a10704d8e3c6..d50df998d3aa 100644
@@ -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);
 

A message that is not in the archive (sent off-list or not yet received): CAOc6etYcE-0wbcWxgTH49h1Odepg=Esc_gmfDoUioHOsnNj33Q@mail.gmail.com

#2 lore raw
Quoted 9 lines · Edmundo Carmona Antoranz

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?

Quoted 4 lines
       priv->speed = SPEED_UNKNOWN;
       return 0;