linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]  Fix a potential issue in mpc52xx uart driver
@ 2008-04-29  7:36 Andrew Liu
  2008-05-01 18:07 ` Grant Likely
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Liu @ 2008-04-29  7:36 UTC (permalink / raw)
  To: grant.likely, tnt; +Cc: linuxppc-dev

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.

Signed-off-by: Andrew Liu <shengping.liu@windriver.com>

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);
  }

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix a potential issue in mpc52xx uart driver
  2008-04-29  7:36 [PATCH] Fix a potential issue in mpc52xx uart driver Andrew Liu
@ 2008-05-01 18:07 ` Grant Likely
  0 siblings, 0 replies; 2+ messages in thread
From: Grant Likely @ 2008-05-01 18:07 UTC (permalink / raw)
  To: Andrew Liu; +Cc: linuxppc-dev

On Tue, Apr 29, 2008 at 1:36 AM, Andrew Liu <shengping.liu@windriver.com> wrote:
> 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.
>
>  Signed-off-by: Andrew Liu <shengping.liu@windriver.com>

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.

>
>  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);
>   }
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-05-01 18:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-29  7:36 [PATCH] Fix a potential issue in mpc52xx uart driver Andrew Liu
2008-05-01 18:07 ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).