Re: [PATCH 1/2] serial: amba-pl011: unprepare console clock on unregister

Karl Mehltretter <[email protected]> Sun, 19 Jul 2026 12:27:41 +0200
Newsgroups org.kernel.vger.linux-serial,dev.linux.lists.linux-rt-devel,dev.linux.lists.sashiko-reviews,org.kernel.vger.linux-kernel
Message-ID <alyjOGyTd19Obemi@MacBook-Pro-von-Karl>
On Sun, Jul 19, 2026 at 07:04:54AM +0100, [email protected] wrote:
> 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);

Good catch in a rare error path.  A NULL check alone is not enough
because other callbacks use the same pointer.

The underlying issue is that serial core can leave the console registered
after uart_add_one_port() fails. I will investigate that separately.

Karl