SUPERH platform development
 help / color / mirror / Atom feed
* [PATCH 0/2] sh: kfr2r09: fix i2c adapter leaks
@ 2026-05-08 12:05 Johan Hovold
  2026-05-08 12:06 ` [PATCH 1/2] sh: kfr2r09: fix i2c adapter leak on USB gdaget setup Johan Hovold
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Johan Hovold @ 2026-05-08 12:05 UTC (permalink / raw)
  To: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz
  Cc: linux-sh, linux-kernel, Johan Hovold

The kfr2r09 platform setup code fails to drop the references it acquires
to the I2C adapter.

Johan


Johan Hovold (2):
  sh: kfr2r09: fix i2c adapter leak on USB gdaget setup
  sh: kfr2r09: fix i2c adapter leak on serial console setup

 arch/sh/boards/mach-kfr2r09/setup.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

-- 
2.53.0


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

* [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-06-24  8:29   ` Geert Uytterhoeven
  2026-05-08 12:06 ` [PATCH 2/2] sh: kfr2r09: fix i2c adapter leak on serial console setup Johan Hovold
  2026-06-12 16:00 ` [PATCH 0/2] sh: kfr2r09: fix i2c adapter leaks Johan Hovold
  2 siblings, 1 reply; 8+ 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] 8+ 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
  2026-06-24  8:30   ` Geert Uytterhoeven
  2026-06-12 16:00 ` [PATCH 0/2] sh: kfr2r09: fix i2c adapter leaks Johan Hovold
  2 siblings, 1 reply; 8+ 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] 8+ messages in thread

* Re: [PATCH 0/2] sh: kfr2r09: fix i2c adapter leaks
  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 ` [PATCH 2/2] sh: kfr2r09: fix i2c adapter leak on serial console setup Johan Hovold
@ 2026-06-12 16:00 ` Johan Hovold
  2026-06-13  5:11   ` John Paul Adrian Glaubitz
  2 siblings, 1 reply; 8+ messages in thread
From: Johan Hovold @ 2026-06-12 16:00 UTC (permalink / raw)
  To: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz
  Cc: linux-sh, linux-kernel

On Fri, May 08, 2026 at 02:05:59PM +0200, Johan Hovold wrote:
> The kfr2r09 platform setup code fails to drop the references it acquires
> to the I2C adapter.

> Johan Hovold (2):
>   sh: kfr2r09: fix i2c adapter leak on USB gdaget setup
>   sh: kfr2r09: fix i2c adapter leak on serial console setup

Can these be picked up now?

Johan

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

* Re: [PATCH 0/2] sh: kfr2r09: fix i2c adapter leaks
  2026-06-12 16:00 ` [PATCH 0/2] sh: kfr2r09: fix i2c adapter leaks Johan Hovold
@ 2026-06-13  5:11   ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 8+ messages in thread
From: John Paul Adrian Glaubitz @ 2026-06-13  5:11 UTC (permalink / raw)
  To: Johan Hovold, Yoshinori Sato, Rich Felker; +Cc: linux-sh, linux-kernel

On Fri, 2026-06-12 at 18:00 +0200, Johan Hovold wrote:
> On Fri, May 08, 2026 at 02:05:59PM +0200, Johan Hovold wrote:
> > The kfr2r09 platform setup code fails to drop the references it acquires
> > to the I2C adapter.
> 
> > Johan Hovold (2):
> >   sh: kfr2r09: fix i2c adapter leak on USB gdaget setup
> >   sh: kfr2r09: fix i2c adapter leak on serial console setup
> 
> Can these be picked up now?

I will try to review some patches this weekend.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* Re: [PATCH 1/2] sh: kfr2r09: fix i2c adapter leak on USB gdaget setup
  2026-05-08 12:06 ` [PATCH 1/2] sh: kfr2r09: fix i2c adapter leak on USB gdaget setup Johan Hovold
@ 2026-06-24  8:29   ` Geert Uytterhoeven
  2026-06-25  6:45     ` Johan Hovold
  0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2026-06-24  8:29 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	linux-kernel, stable, Magnus Damm

Hi Johan,

On Fri, 8 May 2026 at 14:06, Johan Hovold <johan@kernel.org> wrote:
> 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>

Thanks for your patch!

> --- 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;

I case i2c_transfer() returns a negative error code (the other
possible value is zero, right?), you might want to propagate that to
the caller. However, the single caller replaces it by -ENODEV anyway,
so I guess your patch is fine.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

>  }
>
>  static int kfr2r09_serial_i2c_setup(void)

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 2/2] sh: kfr2r09: fix i2c adapter leak on serial console setup
  2026-05-08 12:06 ` [PATCH 2/2] sh: kfr2r09: fix i2c adapter leak on serial console setup Johan Hovold
@ 2026-06-24  8:30   ` Geert Uytterhoeven
  0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2026-06-24  8:30 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	linux-kernel, stable, Magnus Damm

Hi Johan,

On Fri, 8 May 2026 at 14:08, Johan Hovold <johan@kernel.org> wrote:
> 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>

Thanks for your patch!

> --- 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;

I case i2c_transfer() returns a negative error code (the other
possible value is zero, right?), you might want to propagate that to
the caller. However, the single caller ignores the return value anyway,
so I guess your patch is fine.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

>  }
>  #else
>  static int kfr2r09_usb0_gadget_i2c_setup(void)

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 1/2] sh: kfr2r09: fix i2c adapter leak on USB gdaget setup
  2026-06-24  8:29   ` Geert Uytterhoeven
@ 2026-06-25  6:45     ` Johan Hovold
  0 siblings, 0 replies; 8+ messages in thread
From: Johan Hovold @ 2026-06-25  6:45 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	linux-kernel, stable, Magnus Damm

Hi Geert,

On Wed, Jun 24, 2026 at 10:29:41AM +0200, Geert Uytterhoeven wrote:

> On Fri, 8 May 2026 at 14:06, Johan Hovold <johan@kernel.org> wrote:
> > 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>

> > @@ -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;
> 
> I case i2c_transfer() returns a negative error code (the other
> possible value is zero, right?), you might want to propagate that to
> the caller. However, the single caller replaces it by -ENODEV anyway,
> so I guess your patch is fine.

Yes, indeed, but that's arguably a separate change. And in this case it
doesn't really matter currently as you point out.
 
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks for reviewing.

Johan

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

end of thread, other threads:[~2026-06-25  6:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-06-24  8:29   ` Geert Uytterhoeven
2026-06-25  6:45     ` Johan Hovold
2026-05-08 12:06 ` [PATCH 2/2] sh: kfr2r09: fix i2c adapter leak on serial console setup Johan Hovold
2026-06-24  8:30   ` Geert Uytterhoeven
2026-06-12 16:00 ` [PATCH 0/2] sh: kfr2r09: fix i2c adapter leaks Johan Hovold
2026-06-13  5:11   ` John Paul Adrian Glaubitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox