From: wu000273@umn.edu
To: kjlu@umn.edu
Cc: wu000273@umn.edu, Michal Simek <michal.simek@xilinx.com>,
Rob Herring <robh@kernel.org>, Wolfram Sang <wsa@kernel.org>,
Shubhrajyoti Datta <shubhraj@xilinx.com>,
linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] i2c: xiic: Fix reference count leaks.
Date: Sat, 13 Jun 2020 16:59:23 -0500 [thread overview]
Message-ID: <20200613215923.2611-1-wu000273@umn.edu> (raw)
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.
Fixes: 36ecbcab84d0 ("i2c: xiic: Implement power management")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
drivers/i2c/busses/i2c-xiic.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 90c1c362394d..ffec41e6be72 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -696,8 +696,10 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
xiic_getreg8(i2c, XIIC_SR_REG_OFFSET));
err = pm_runtime_get_sync(i2c->dev);
- if (err < 0)
+ if (err < 0) {
+ pm_runtime_put_noidle(i2c->dev);
return err;
+ }
err = xiic_busy(i2c);
if (err)
@@ -860,8 +862,10 @@ static int xiic_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(&i2c->adap);
ret = pm_runtime_get_sync(i2c->dev);
- if (ret < 0)
+ if (ret < 0) {
+ pm_runtime_put_noidle(i2c->dev);
return ret;
+ }
xiic_deinit(i2c);
pm_runtime_put_sync(i2c->dev);
--
2.17.1
next reply other threads:[~2020-06-13 21:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-13 21:59 wu000273 [this message]
2020-06-14 9:09 ` [PATCH] i2c: xiic: Fix reference count leaks Wolfram Sang
2020-06-17 14:30 ` David Laight
2020-07-13 7:54 ` Michal Simek
[not found] ` <CAMV6ehHR2+OSxj7rbWG_=ef2=aemecFk9u0yNSHN1keZZ3j5Bg@mail.gmail.com>
2020-07-21 6:02 ` Michal Simek
[not found] ` <CAMV6ehFtXcC-ba7RT95AC2bryh0E-9W1YYfkUBbZGDcLLL_6JA@mail.gmail.com>
2020-07-27 6:46 ` Michal Simek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200613215923.2611-1-wu000273@umn.edu \
--to=wu000273@umn.edu \
--cc=kjlu@umn.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@xilinx.com \
--cc=robh@kernel.org \
--cc=shubhraj@xilinx.com \
--cc=wsa@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).