Re: [PATCH v6 1/3] serial: 8250: fix deadlock in serial8250_register_ports()
From: Ilpo Järvinen
Date: Wed Sep 30 2026 - 03:58:56 EST
On Wed, 30 Sep 2026, Hui Peng wrote:
> In serial8250_register_ports(), mutex_lock(&hash_mutex) is acquired while
> holding spinlock_t serial_port_lock during IRQ chain registration:
>
> spin_lock_irqsave(&serial_port_lock, flags);
> mutex_lock(&hash_mutex);
>
> Acquiring a sleeping mutex while holding a spinlock causes a
> sleeping-while-atomic bug and potential deadlock.
>
> Replace mutex_lock(&hash_mutex) with spin_lock_irqsave() in
> serial8250_register_ports().
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@xxxxxxxxxxxxxxx
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
> Assisted-by: LLM
> Signed-off-by: Hui Peng <benquike@xxxxxxxxx>
> ---
> drivers/tty/serial/8250/8250_core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
> index 9e4f5a2a2eaa..f64a1b0a2eaa 100644
> --- a/drivers/tty/serial/8250/8250_core.c
> +++ b/drivers/tty/serial/8250/8250_core.c
> @@ -102,9 +102,9 @@ static void serial8250_register_ports(struct uart_driver *drv,
> struct uart_8250_port *up;
>
> for (i = 0; i < nr; i++) {
> - up = &serial8250_ports[i];
> + up = &serial8250_ports[i];
> up->port.dev = dev;
You failed to check what garbage AI outputted for you? Please, please
don't waste our time sending unfiltered AI output.
--
i.