* [PATCH 1/2] sh: kfr2r09: fix i2c adapter leak on USB gdaget setup
2026-05-08 12:05 [PATCH 0/2] sh: kfr2r09: fix i2c adapter leaks Johan Hovold
@ 2026-05-08 12:06 ` Johan Hovold
2026-05-08 12:06 ` [PATCH 2/2] sh: kfr2r09: fix i2c adapter leak on serial console setup Johan Hovold
1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2026-05-08 12:06 UTC (permalink / raw)
To: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz
Cc: linux-sh, linux-kernel, Johan Hovold, stable, Magnus Damm
Make sure to drop the reference taken to the I2C adapter (and its
module) when enabling USB gadget mode which prevents the adapter from
ever being deregistered.
Fixes: 5a1c4cb5bc22 ("sh: add r8a66597 usb0 gadget to the kfr2r09 board")
Cc: stable@vger.kernel.org # 2.6.32
Cc: Magnus Damm <damm@igel.co.jp>
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 70236859919d..62af9a9db039 100644
--- a/arch/sh/boards/mach-kfr2r09/setup.c
+++ b/arch/sh/boards/mach-kfr2r09/setup.c
@@ -368,7 +368,7 @@ static int kfr2r09_usb0_gadget_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;
@@ -377,7 +377,7 @@ static int kfr2r09_usb0_gadget_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 << 1);
buf[0] = 0x13;
@@ -387,9 +387,16 @@ static int kfr2r09_usb0_gadget_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;
}
static int kfr2r09_serial_i2c_setup(void)
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] sh: kfr2r09: fix i2c adapter leak on serial console setup
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
1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2026-05-08 12:06 UTC (permalink / raw)
To: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz
Cc: linux-sh, linux-kernel, Johan Hovold, stable, Magnus Damm
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
^ permalink raw reply related [flat|nested] 3+ messages in thread