Re: [PATCH 1/2] serial: amba-pl011: unprepare console clock on unregister
From: Karl Mehltretter
Date: Sun Jul 19 2026 - 06:28:32 EST
On Sun, Jul 19, 2026 at 07:04:54AM +0100, sashiko-bot@xxxxxxxxxx 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