diff options
author | Marek Roszko <mark.roszko@gmail.com> | 2014-01-07 05:45:06 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-06 14:08:14 -0500 |
commit | 630cf7648cd47e83ddb674aaa4e4c245a6736f10 (patch) | |
tree | 585e0961b24e77ff7a352240ccba886baa55cb51 | |
parent | d0db59cf6e28f8cd8958681bd9264375bbdde2c9 (diff) |
tty/serial: at91: Handle shutdown more safely
commit 0cc7c6c7916b1b6f34350ff1473b80b9f7e459c0 upstream.
Interrupts were being cleaned up late in the shutdown handler, it is possible
that an interrupt can occur and schedule a tasklet that runs after the port is
cleaned up. There is a null dereference due to this race condition with the
following stacktrace:
[<c02092b0>] (atmel_tasklet_func+0x514/0x814) from [<c001fd34>] (tasklet_action+0x70/0xa8)
[<c001fd34>] (tasklet_action+0x70/0xa8) from [<c001f60c>] (__do_softirq+0x90/0x144)
[<c001f60c>] (__do_softirq+0x90/0x144) from [<c001fa18>] (irq_exit+0x40/0x4c)
[<c001fa18>] (irq_exit+0x40/0x4c) from [<c000e298>] (handle_IRQ+0x64/0x84)
[<c000e298>] (handle_IRQ+0x64/0x84) from [<c000d6c0>] (__irq_svc+0x40/0x50)
[<c000d6c0>] (__irq_svc+0x40/0x50) from [<c0208060>] (atmel_rx_dma_release+0x88/0xb8)
[<c0208060>] (atmel_rx_dma_release+0x88/0xb8) from [<c0209740>] (atmel_shutdown+0x104/0x160)
[<c0209740>] (atmel_shutdown+0x104/0x160) from [<c0205e8c>] (uart_port_shutdown+0x2c/0x38)
Signed-off-by: Marek Roszko <mark.roszko@gmail.com>
Acked-by: Leilei Zhao <leilei.zhao@atmel.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/serial/atmel_serial.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 3467462869ce..82127ac26d6f 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c | |||
@@ -1022,12 +1022,24 @@ static int atmel_startup(struct uart_port *port) | |||
1022 | static void atmel_shutdown(struct uart_port *port) | 1022 | static void atmel_shutdown(struct uart_port *port) |
1023 | { | 1023 | { |
1024 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | 1024 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); |
1025 | |||
1025 | /* | 1026 | /* |
1026 | * Ensure everything is stopped. | 1027 | * Clear out any scheduled tasklets before |
1028 | * we destroy the buffers | ||
1029 | */ | ||
1030 | tasklet_kill(&atmel_port->tasklet); | ||
1031 | |||
1032 | /* | ||
1033 | * Ensure everything is stopped and | ||
1034 | * disable all interrupts, port and break condition. | ||
1027 | */ | 1035 | */ |
1028 | atmel_stop_rx(port); | 1036 | atmel_stop_rx(port); |
1029 | atmel_stop_tx(port); | 1037 | atmel_stop_tx(port); |
1030 | 1038 | ||
1039 | UART_PUT_CR(port, ATMEL_US_RSTSTA); | ||
1040 | UART_PUT_IDR(port, -1); | ||
1041 | |||
1042 | |||
1031 | /* | 1043 | /* |
1032 | * Shut-down the DMA. | 1044 | * Shut-down the DMA. |
1033 | */ | 1045 | */ |
@@ -1054,12 +1066,6 @@ static void atmel_shutdown(struct uart_port *port) | |||
1054 | } | 1066 | } |
1055 | 1067 | ||
1056 | /* | 1068 | /* |
1057 | * Disable all interrupts, port and break condition. | ||
1058 | */ | ||
1059 | UART_PUT_CR(port, ATMEL_US_RSTSTA); | ||
1060 | UART_PUT_IDR(port, -1); | ||
1061 | |||
1062 | /* | ||
1063 | * Free the interrupt | 1069 | * Free the interrupt |
1064 | */ | 1070 | */ |
1065 | free_irq(port->irq, port); | 1071 | free_irq(port->irq, port); |