tty/serial: at91: correct the usage of tasklet
authorLeilei Zhao <leilei.zhao@atmel.com>
Fri, 27 Feb 2015 08:07:18 +0000 (16:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Mar 2015 02:51:47 +0000 (03:51 +0100)
The tasklet may be scheduled and executed after serial port
was shutdown, for example, DMA rx callback will schedule the
tasklet while serial port is shutting down, especially serial
port is sending and receiving data in a higher baud rate and
it's killed by external program. In this case, tasklet_kill
can only clear the current scheduling out, so tasklet should
be disabled to prevent being executed in later scheduling.
Otherwise, the tasklet executed after serial port was shutdown
can lead to kernel crash.

Signed-off-by: Leilei Zhao <leilei.zhao@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/atmel_serial.c

index 8fac877bc3d412da7f0b878bdc82d2132c36a19f..b45a4809031e6d645d975d371fed314f5c1601b2 100644 (file)
@@ -1755,6 +1755,8 @@ static int atmel_startup(struct uart_port *port)
        if (retval)
                goto free_irq;
 
+       tasklet_enable(&atmel_port->tasklet);
+
        /*
         * Initialize DMA (if necessary)
         */
@@ -1858,6 +1860,7 @@ static void atmel_shutdown(struct uart_port *port)
         * Clear out any scheduled tasklets before
         * we destroy the buffers
         */
+       tasklet_disable(&atmel_port->tasklet);
        tasklet_kill(&atmel_port->tasklet);
 
        /*
@@ -2251,6 +2254,7 @@ static int atmel_init_port(struct atmel_uart_port *atmel_port,
 
        tasklet_init(&atmel_port->tasklet, atmel_tasklet_func,
                        (unsigned long)port);
+       tasklet_disable(&atmel_port->tasklet);
 
        memset(&atmel_port->rx_ring, 0, sizeof(atmel_port->rx_ring));
 
This page took 0.029211 seconds and 5 git commands to generate.