[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210408111930.203574-1-yeweihua4@huawei.com>
Date: Thu, 8 Apr 2021 19:19:30 +0800
From: Ye Weihua <yeweihua4@...wei.com>
To: <aisheng.dong@....com>, <shawnguo@...nel.org>,
<s.hauer@...gutronix.de>, <kernel@...gutronix.de>,
<festevam@...il.com>, <linux-imx@....com>
CC: <linux-i2c@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <yangjihong1@...wei.com>,
<zhangjinhao2@...wei.com>
Subject: [PATCH -next] i2c: imx-lpi2c: fix PM reference leak in lpi2c_imx_master_enable()
The PM reference count is not expected to be incremented on return in
ipi2c_imx_master_enable().
However, pm_runtime_get_sync() will increment the PM reference count
even on failure. forgetting to put the reference again will result in
a leak.
Replace it with pm_runtime_resume_and_get() to keep the usage counter
balanced.
Reported-by: Hulk Robot <hulkci@...wei.com>
Signed-off-by: Ye Weihua <yeweihua4@...wei.com>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
index 9db6ccded5e9..8b9ba055c418 100644
--- a/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -259,7 +259,7 @@ static int lpi2c_imx_master_enable(struct lpi2c_imx_struct *lpi2c_imx)
unsigned int temp;
int ret;
- ret = pm_runtime_get_sync(lpi2c_imx->adapter.dev.parent);
+ ret = pm_runtime_resume_and_get(lpi2c_imx->adapter.dev.parent);
if (ret < 0)
return ret;
--
2.17.1
Powered by blists - more mailing lists