mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
hwmon: (ina3221) Fix PM usage counter unbalance in ina3221_write_enable
[ Upstream commitbce776f100] 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:323aeb0eb5("hwmon: (ina3221) Add PM runtime support") Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com> Link: https://lore.kernel.org/r/20201202145320.1135614-1-zhangqilong3@huawei.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a08dbd0120
commit
55dbc5e2d9
@@ -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 */
|
/* For enabling routine, increase refcount and resume() at first */
|
||||||
if (enable) {
|
if (enable) {
|
||||||
ret = pm_runtime_get_sync(ina->pm_dev);
|
ret = pm_runtime_resume_and_get(ina->pm_dev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "Failed to get PM runtime\n");
|
dev_err(dev, "Failed to get PM runtime\n");
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user