lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <1624959329-71785-1-git-send-email-zou_wei@huawei.com>
Date:   Tue, 29 Jun 2021 17:35:29 +0800
From:   Zou Wei <zou_wei@...wei.com>
To:     <thierry.reding@...il.com>, <u.kleine-koenig@...gutronix.de>,
        <lee.jones@...aro.org>
CC:     <linux-pwm@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        Zou Wei <zou_wei@...wei.com>
Subject: [PATCH -next v2] 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

Reported-by: Hulk Robot <hulkci@...wei.com>
Signed-off-by: Zou Wei <zou_wei@...wei.com>
---
 drivers/pwm/pwm-img.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
index cc37054..d58ee47 100644
--- a/drivers/pwm/pwm-img.c
+++ b/drivers/pwm/pwm-img.c
@@ -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);
-- 
2.6.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ