* [PATCH v2] hwmon: (ina3221) Fix PM usage counter unbalance in ina3221_write_enable
@ 2020-12-02 14:53 Zhang Qilong
2020-12-03 1:42 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Zhang Qilong @ 2020-12-02 14:53 UTC (permalink / raw)
To: jdelvare, linux; +Cc: linux-hwmon
pm_runtime_get_sync will increment pm usage counter
even it failed. Forgetting to putting operation will
result in reference leak here. We fix it by replacing
it with pm_runtime_resume_and_get to keep usage counter
balanced. It depends on the mainline commit[PM: runtime:
Add pm_runtime_resume_and_get to deal with usagecounter].
Fixes: 323aeb0eb5d9a ("hwmon: (ina3221) Add PM runtime support")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
Changlog:
v2
- add the dependency for the fix.
---
drivers/hwmon/ina3221.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c
index 72cfdc007e60..d80bd3efcd6d 100644
--- a/drivers/hwmon/ina3221.c
+++ b/drivers/hwmon/ina3221.c
@@ -489,7 +489,7 @@ static int ina3221_write_enable(struct device *dev, int channel, bool enable)
/* For enabling routine, increase refcount and resume() at first */
if (enable) {
- ret = pm_runtime_get_sync(ina->pm_dev);
+ ret = pm_runtime_resume_and_get(ina->pm_dev);
if (ret < 0) {
dev_err(dev, "Failed to get PM runtime\n");
return ret;
--
2.25.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] hwmon: (ina3221) Fix PM usage counter unbalance in ina3221_write_enable
2020-12-02 14:53 [PATCH v2] hwmon: (ina3221) Fix PM usage counter unbalance in ina3221_write_enable Zhang Qilong
@ 2020-12-03 1:42 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2020-12-03 1:42 UTC (permalink / raw)
To: Zhang Qilong; +Cc: jdelvare, linux-hwmon
On Wed, Dec 02, 2020 at 10:53:20PM +0800, Zhang Qilong wrote:
> pm_runtime_get_sync will increment pm usage counter
> even it failed. Forgetting to putting operation will
> result in reference leak here. We fix it by replacing
> it with pm_runtime_resume_and_get to keep usage counter
> balanced. It depends on the mainline commit[PM: runtime:
> Add pm_runtime_resume_and_get to deal with usagecounter].
>
> Fixes: 323aeb0eb5d9a ("hwmon: (ina3221) Add PM runtime support")
> Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Applied (again), this time on top of v5.10-rc6.
> ---
> Changlog:
> v2
> - add the dependency for the fix.
> ---
> drivers/hwmon/ina3221.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c
> index 72cfdc007e60..d80bd3efcd6d 100644
> --- a/drivers/hwmon/ina3221.c
> +++ b/drivers/hwmon/ina3221.c
> @@ -489,7 +489,7 @@ static int ina3221_write_enable(struct device *dev, int channel, bool enable)
>
> /* For enabling routine, increase refcount and resume() at first */
> if (enable) {
> - ret = pm_runtime_get_sync(ina->pm_dev);
> + ret = pm_runtime_resume_and_get(ina->pm_dev);
> if (ret < 0) {
> dev_err(dev, "Failed to get PM runtime\n");
> return ret;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-12-03 1:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-02 14:53 [PATCH v2] hwmon: (ina3221) Fix PM usage counter unbalance in ina3221_write_enable Zhang Qilong
2020-12-03 1:42 ` Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.