linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: busses: Fix reference count leaks.
@ 2020-06-13 22:14 wu000273
  2020-06-14  9:51 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: wu000273 @ 2020-06-13 22:14 UTC (permalink / raw)
  To: kjlu
  Cc: wu000273, Wolfram Sang, Dejin Zheng, Robert Richter,
	Andy Shevchenko, Thor Thayer, Thomas Gleixner, linux-i2c,
	linux-kernel

From: Qiushi Wu <wu000273@umn.edu>

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus call pm_runtime_put_noidle()
if pm_runtime_get_sync() fails.

Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
 drivers/i2c/busses/i2c-img-scb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
index 98a89301ed2a..e13ca862fa97 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -1058,8 +1058,10 @@ static int img_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
 	}
 
 	ret = pm_runtime_get_sync(adap->dev.parent);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_noidle(adap->dev.parent);
 		return ret;
+	}
 
 	for (i = 0; i < num; i++) {
 		struct i2c_msg *msg = &msgs[i];
@@ -1159,8 +1161,10 @@ static int img_i2c_init(struct img_i2c *i2c)
 	int ret;
 
 	ret = pm_runtime_get_sync(i2c->adap.dev.parent);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_noidle(i2c->adap.dev.parent);
 		return ret;
+	}
 
 	rev = img_i2c_readl(i2c, SCB_CORE_REV_REG);
 	if ((rev & 0x00ffffff) < 0x00020200) {
-- 
2.17.1


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

* Re: [PATCH] i2c: busses: Fix reference count leaks.
  2020-06-13 22:14 [PATCH] i2c: busses: Fix reference count leaks wu000273
@ 2020-06-14  9:51 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2020-06-14  9:51 UTC (permalink / raw)
  To: wu000273
  Cc: Kangjie Lu, Wolfram Sang, Dejin Zheng, Robert Richter,
	Andy Shevchenko, Thor Thayer, Thomas Gleixner, linux-i2c,
	Linux Kernel Mailing List

On Sun, Jun 14, 2020 at 1:17 AM <wu000273@umn.edu> wrote:
>
> From: Qiushi Wu <wu000273@umn.edu>
>
> pm_runtime_get_sync() increments the runtime PM usage counter even
> when it returns an error code. Thus call pm_runtime_put_noidle()
> if pm_runtime_get_sync() fails.
>

FWIW,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
> ---
>  drivers/i2c/busses/i2c-img-scb.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
> index 98a89301ed2a..e13ca862fa97 100644
> --- a/drivers/i2c/busses/i2c-img-scb.c
> +++ b/drivers/i2c/busses/i2c-img-scb.c
> @@ -1058,8 +1058,10 @@ static int img_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
>         }
>
>         ret = pm_runtime_get_sync(adap->dev.parent);
> -       if (ret < 0)
> +       if (ret < 0) {
> +               pm_runtime_put_noidle(adap->dev.parent);
>                 return ret;
> +       }
>
>         for (i = 0; i < num; i++) {
>                 struct i2c_msg *msg = &msgs[i];
> @@ -1159,8 +1161,10 @@ static int img_i2c_init(struct img_i2c *i2c)
>         int ret;
>
>         ret = pm_runtime_get_sync(i2c->adap.dev.parent);
> -       if (ret < 0)
> +       if (ret < 0) {
> +               pm_runtime_put_noidle(i2c->adap.dev.parent);
>                 return ret;
> +       }
>
>         rev = img_i2c_readl(i2c, SCB_CORE_REV_REG);
>         if ((rev & 0x00ffffff) < 0x00020200) {
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2020-06-14  9:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-13 22:14 [PATCH] i2c: busses: Fix reference count leaks wu000273
2020-06-14  9:51 ` Andy Shevchenko

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).