Skip to contentSkip to conversation

pwm: img: Call pm_runtime_put_autosuspend() in pm_runtime_get_sync() failed case

PATCH New Zou Wei 1 participant 1 message Jun 29, 2021 PWM

lore
Share & tools
lore

Zou Wei

author
#0 lore raw

PATCH v2 1/1 pwm: img: Call pm_runtime_put_autosuspend() in pm_runtime_get_sync() failed case

pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to putting operation will result in reference leak here. Fix it by call pm_runtime_put_autosuspend() in pm_runtime_get_sync() to keep usage counter balanced.

v1-->v2:
call pm_runtime_put_autosuspend() to keep consistency

---
 drivers/pwm/pwm-img.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pwm/pwm-img.c +3 -1
index cc37054..d58ee47 100644
@@ -157,8 +157,10 @@ static int img_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 	int ret;
 
 	ret = pm_runtime_get_sync(chip->dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_autosuspend(chip->dev);
 		return ret;
+	}
 
 	val = img_pwm_readl(pwm_chip, PWM_CTRL_CFG);
 	val |= BIT(pwm->hwpwm);
Signature · 1 line
2.6.2