linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] i2c: imx-lpi2c: fix PM reference leak in lpi2c_imx_master_enable()
@ 2021-04-08 11:19 Ye Weihua
  2021-04-14  7:56 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Ye Weihua @ 2021-04-08 11:19 UTC (permalink / raw)
  To: aisheng.dong, shawnguo, s.hauer, kernel, festevam, linux-imx
  Cc: linux-i2c, linux-arm-kernel, linux-kernel, yangjihong1, zhangjinhao2

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@huawei.com>
Signed-off-by: Ye Weihua <yeweihua4@huawei.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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next] i2c: imx-lpi2c: fix PM reference leak in lpi2c_imx_master_enable()
  2021-04-08 11:19 [PATCH -next] i2c: imx-lpi2c: fix PM reference leak in lpi2c_imx_master_enable() Ye Weihua
@ 2021-04-14  7:56 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2021-04-14  7:56 UTC (permalink / raw)
  To: Ye Weihua
  Cc: aisheng.dong, shawnguo, s.hauer, kernel, festevam, linux-imx,
	linux-i2c, linux-arm-kernel, linux-kernel, yangjihong1,
	zhangjinhao2


[-- Attachment #1.1: Type: text/plain, Size: 636 bytes --]

On Thu, Apr 08, 2021 at 07:19:30PM +0800, Ye Weihua wrote:
> 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@huawei.com>
> Signed-off-by: Ye Weihua <yeweihua4@huawei.com>

Thanks, yet I applied this series now:

http://patchwork.ozlabs.org/project/linux-i2c/list/?series=217733&state=*


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-14  7:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 11:19 [PATCH -next] i2c: imx-lpi2c: fix PM reference leak in lpi2c_imx_master_enable() Ye Weihua
2021-04-14  7:56 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).