All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Karl Mehltretter" <kmehltretter@gmail.com>
Cc: linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] serial: amba-pl011: unprepare console clock on unregister
Date: Sun, 19 Jul 2026 07:04:54 +0000	[thread overview]
Message-ID: <20260719070454.D6FA21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260719063502.18852-2-kmehltretter@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing NULL check for `uap` in console callbacks leads to kernel panic if `uart_add_one_port` fails.
--

--- Patch [1]: [PATCH 1/2] serial: amba-pl011: unprepare console clock on unregister ---
commit 7c5636c95e763ddaf7574887aeb1e24ce1d44fec
Author: Karl Mehltretter <kmehltretter@gmail.com>

serial: amba-pl011: unprepare console clock on unregister

This patch adds a console .exit() callback that calls clk_unprepare() on the
UART clock when the console is unregistered. This balances the clk_prepare()
called in pl011_console_setup().

> diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
> index 8ed91e1da22be..1aa43994a3cdc 100644
> --- a/drivers/tty/serial/amba-pl011.c
> +++ b/drivers/tty/serial/amba-pl011.c
> @@ -2552,6 +2552,15 @@ static int pl011_console_setup(struct console *co, char *options)
>  	return uart_set_options(&uap->port, co, baud, parity, bits, flow);
>  }
>  
> +static int pl011_console_exit(struct console *co)
> +{
> +	struct uart_amba_port *uap = amba_ports[co->index];
> +

[Severity: High]
This is a pre-existing issue, but does uap need a NULL check here to
prevent a kernel panic on error paths?

If uart_add_one_port() fails internally (e.g., an allocation failure in
serial_core_add_one_port() returning -ENOMEM), it returns an error but
crucially fails to unregister the console that was already registered
earlier in uart_configure_port().

The caller sees the error and clears the pointer:

drivers/tty/serial/amba-pl011.c:pl011_register_port() {
    ...
    ret = uart_add_one_port(&amba_reg, &uap->port);
    if (ret)
        pl011_unregister_port(uap);
    ...
}

Because pl011_unregister_port() clears amba_ports[co->index] to NULL, but
the console remains active in the system's console list, will
unconditionally dereferencing uap here (and in pl011_console_write_atomic)
cause a crash when invoked?

> +	clk_unprepare(uap->clk);
> +
> +	return 0;
> +}
> +

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260719063502.18852-1-kmehltretter@gmail.com?part=1

  reply	other threads:[~2026-07-19  7:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-19  6:35 [PATCH 0/2] serial: amba-pl011: fix console clock lifetime Karl Mehltretter
2026-07-19  6:35 ` [PATCH 1/2] serial: amba-pl011: unprepare console clock on unregister Karl Mehltretter
2026-07-19  7:04   ` sashiko-bot [this message]
2026-07-19 10:27     ` Karl Mehltretter
2026-07-19  6:35 ` [PATCH 2/2] serial: amba-pl011: keep console clock enabled for atomic writes Karl Mehltretter
2026-07-19  6:52   ` sashiko-bot
2026-07-20  8:01     ` Sebastian Andrzej Siewior
2026-07-20  8:13       ` John Ogness
2026-07-20  8:26         ` Sebastian Andrzej Siewior
2026-07-20 21:26           ` Karl Mehltretter
2026-07-20 11:45   ` Petr Mladek
2026-07-20 12:15     ` Sebastian Andrzej Siewior

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=20260719070454.D6FA21F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kmehltretter@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.