From: Lars-Peter Clausen <lars@metafoo.de>
To: Wolfram Sang <wsa@kernel.org>
Cc: Michal Simek <michal.simek@amd.com>,
Shubhrajyoti Datta <Shubhrajyoti.datta@amd.com>,
linux-i2c@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 1/2] i2c: cadence: cdns_i2c_master_xfer(): Fix runtime PM leak on error path
Date: Thu, 13 Apr 2023 19:10:21 -0700 [thread overview]
Message-ID: <20230414021022.505291-1-lars@metafoo.de> (raw)
The cdns_i2c_master_xfer() function gets a runtime PM reference when the
function is entered. This reference is released when the function is
exited. There is currently one error path where the function exits
directly, which leads to a leak of the runtime PM reference.
Make sure that this error path also releases the runtime PM reference.
Fixes: 1a351b10b967 ("i2c: cadence: Added slave support")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/i2c/busses/i2c-cadence.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index f1a67c410ad3..3a4edf7e75f9 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -834,8 +834,10 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
#if IS_ENABLED(CONFIG_I2C_SLAVE)
/* Check i2c operating mode and switch if possible */
if (id->dev_mode == CDNS_I2C_MODE_SLAVE) {
- if (id->slave_state != CDNS_I2C_SLAVE_STATE_IDLE)
- return -EAGAIN;
+ if (id->slave_state != CDNS_I2C_SLAVE_STATE_IDLE) {
+ ret = -EAGAIN;
+ goto out;
+ }
/* Set mode to master */
cdns_i2c_set_mode(CDNS_I2C_MODE_MASTER, id);
--
2.30.2
next reply other threads:[~2023-04-14 2:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-14 2:10 Lars-Peter Clausen [this message]
2023-04-14 2:10 ` [PATCH 2/2] i2c: xiic: xiic_xfer(): Fix runtime PM leak on error path Lars-Peter Clausen
2023-04-14 12:57 ` Michal Simek
2023-04-18 16:44 ` Wolfram Sang
2023-04-14 12:57 ` [PATCH 1/2] i2c: cadence: cdns_i2c_master_xfer(): " Michal Simek
2023-04-18 16:44 ` Wolfram Sang
2023-04-24 9:28 ` Wolfram Sang
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=20230414021022.505291-1-lars@metafoo.de \
--to=lars@metafoo.de \
--cc=Shubhrajyoti.datta@amd.com \
--cc=linux-i2c@vger.kernel.org \
--cc=michal.simek@amd.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