Re: [PATCH v1] serial: sh-sci: fix memory region release in error path
From: Geert Uytterhoeven
Date: Thu Apr 16 2026 - 08:00:40 EST
Hi Zeng,
On Mon, 13 Apr 2026 at 06:08, zenghongling <zenghongling@xxxxxxxxxx> wrote:
> From: Hongling Zeng <zenghongling@xxxxxxxxxx>
>
> The sci_request_port() function uses request_mem_region() to reserve
> I/O memory, but in the error path when sci_remap_port() fails, it
> incorrectly calls release_resource() instead of release_mem_region().
>
> This mismatch can cause resource accounting issues. Fix it by using
> the correct release function, consistent with sci_release_port().
Thanks for your patch!
> Fixes: 2667bd6673eb ("serial: 8250_port: simplify serial8250_request_std_resource()")
That commit does not touch the sh-sci driver. Shouldn't that be
Fixes: e2651647080930a1 ("serial: sh-sci: Handle port memory region
reservations.")
instead?
"git log --follow" does a really bad job here, and doesn't even see the
offending commit, due to the actual change happening in parallel with
the move from drivers/serial to drivers/tty/serial. Fortunately the
"git blame"-style output in the linked report below does show the
correct commit.
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Reported-by: Dan Carpenter <error27@xxxxxxxxx>
> Closes: https://lore.kernel.org/r/202604032356.SzEjYkBC-lkp@xxxxxxxxx/
> Signed-off-by: Hongling Zeng <zenghongling@xxxxxxxxxx>
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -3024,7 +3024,7 @@ int sci_request_port(struct uart_port *port)
>
> ret = sci_remap_port(port);
> if (unlikely(ret != 0)) {
> - release_resource(res);
> + release_mem_region(port->mapbase, sport->reg_size);
> return ret;
> }
>
My first thought was "Isn't release_resource() just a shorthand in
case you already have a pointer to the resource?", but that indeed
seems to leak the resource, as it doesn't call free_resource()
(see __release_region()).
Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
Still, I'd like to see a second review opinion.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
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