Skip to contentSkip to conversation

Fix a potential issue in mpc52xx uart driver

PATCH In review Andrew Liu 2 participants 2 messages Apr 29, 2008 – May 1, 2008

lore
Share & tools
lore

Andrew Liu

author
#0 lore raw

PATCH 1/1 Fix a potential issue in mpc52xx uart driver

mpc52xx_uart_int and __uart_put_char both try to acquire the port->lock. Therefore the function sequence of:

mpc52xx_uart_int--> ...-->flush_to_ldisc-->...-->__uart_put_char

can potentially trigger a deadlock. To avoid this deadlock a fix similar to that found in the 8250.c serial driver is applied. The deadlock is avoided by releasing the lock before pushing a buffer and reacquiring it when completed.

drivers/serial/mpc52xx_uart.c +2 -0
index d93b357..5f95e53 100644
@@ -783,7 +783,9 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port)
                }
        }
 
+       spin_unlock(&port->lock);
        tty_flip_buffer_push(tty);
+       spin_lock(&port->lock);
 
        return psc_ops->raw_rx_rdy(port);
 }
#1 lore raw
Quoted 11 lines · Andrew Liu

mpc52xx_uart_int and __uart_put_char both try to acquire the
port->lock. Therefore the function sequence of:

mpc52xx_uart_int--> ...-->flush_to_ldisc-->...-->__uart_put_char

can potentially trigger a deadlock. To avoid this deadlock a fix similar to that found in the 8250.c serial driver is applied. The deadlock is avoided by releasing the lock before pushing a buffer and reacquiring it when completed.

Your patch is whitespace damaged and does not apply (tabs have been converted to spaces). It was trivial so I've applied it manually, but please be careful when posting future patches.

Thanks,
g.

Quoted 16 lines

diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index d93b357..5f95e53 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -783,7 +783,9 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port)

                }
        }
 +       spin_unlock(&port->lock);
        tty_flip_buffer_push(tty);

+ spin_lock(&port->lock);

        return psc_ops->raw_rx_rdy(port);

}

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.