pwm: img: Fix PM reference leak in img_pwm_enable()
authorZou Wei <zou_wei@huawei.com>
Wed, 12 May 2021 03:57:17 +0000 (11:57 +0800)
committerThierry Reding <thierry.reding@gmail.com>
Wed, 30 Jun 2021 17:12:18 +0000 (19:12 +0200)
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 replacing it with pm_runtime_resume_and_get to keep usage
counter balanced.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zou Wei <zou_wei@huawei.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-img.c

index cc37054589ccf8d470604b3a8a435c37d0dbf43e..11b16ecc4f96777f427732e6c42ab1678d823410 100644 (file)
@@ -156,7 +156,7 @@ static int img_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
        struct img_pwm_chip *pwm_chip = to_img_pwm_chip(chip);
        int ret;
 
-       ret = pm_runtime_get_sync(chip->dev);
+       ret = pm_runtime_resume_and_get(chip->dev);
        if (ret < 0)
                return ret;