From: Johan Hovold <johan@kernel.org>
To: Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>,
stable@vger.kernel.org, Magnus Damm <damm@opensource.se>
Subject: [PATCH 2/2] sh: kfr2r09: fix i2c adapter leak on serial console setup
Date: Fri, 8 May 2026 14:06:01 +0200 [thread overview]
Message-ID: <20260508120601.426115-3-johan@kernel.org> (raw)
In-Reply-To: <20260508120601.426115-1-johan@kernel.org>
Make sure to drop the reference taken to the I2C adapter (and its
module) when setting up the serial console which prevents the adapter
from ever being deregistered.
Fixes: e6d8460aca63 ("sh: Improve kfr2r09 serial port setup code")
Cc: stable@vger.kernel.org # 2.6.33
Cc: Magnus Damm <damm@opensource.se>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
arch/sh/boards/mach-kfr2r09/setup.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/arch/sh/boards/mach-kfr2r09/setup.c b/arch/sh/boards/mach-kfr2r09/setup.c
index 62af9a9db039..8f436bcc1ae1 100644
--- a/arch/sh/boards/mach-kfr2r09/setup.c
+++ b/arch/sh/boards/mach-kfr2r09/setup.c
@@ -418,7 +418,7 @@ static int kfr2r09_serial_i2c_setup(void)
msg.flags = 0;
ret = i2c_transfer(a, &msg, 1);
if (ret != 1)
- return -ENODEV;
+ goto err_put_adapter;
buf[0] = 0;
msg.addr = 0x09;
@@ -427,7 +427,7 @@ static int kfr2r09_serial_i2c_setup(void)
msg.flags = I2C_M_RD;
ret = i2c_transfer(a, &msg, 1);
if (ret != 1)
- return -ENODEV;
+ goto err_put_adapter;
buf[1] = buf[0] | (1 << 6);
buf[0] = 0x13;
@@ -437,9 +437,16 @@ static int kfr2r09_serial_i2c_setup(void)
msg.flags = 0;
ret = i2c_transfer(a, &msg, 1);
if (ret != 1)
- return -ENODEV;
+ goto err_put_adapter;
+
+ i2c_put_adapter(a);
return 0;
+
+err_put_adapter:
+ i2c_put_adapter(a);
+
+ return -ENODEV;
}
#else
static int kfr2r09_usb0_gadget_i2c_setup(void)
--
2.53.0
prev parent reply other threads:[~2026-05-08 12:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 12:05 [PATCH 0/2] sh: kfr2r09: fix i2c adapter leaks Johan Hovold
2026-05-08 12:06 ` [PATCH 1/2] sh: kfr2r09: fix i2c adapter leak on USB gdaget setup Johan Hovold
2026-05-08 12:06 ` Johan Hovold [this message]
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=20260508120601.426115-3-johan@kernel.org \
--to=johan@kernel.org \
--cc=dalias@libc.org \
--cc=damm@opensource.se \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=ysato@users.sourceforge.jp \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.