Commit f50c995f authored by Marek Roszko's avatar Marek Roszko Committed by Greg Kroah-Hartman

tty/serial: at91: fix race condition in atmel_serial_remove

The _remove callback could be called when a tasklet is scheduled. tasklet_kill
was called inside the function in order to free up any scheduled tasklets.
However it was called after uart_remove_one_port which destroys tty references
needed in the port for atmel_tasklet_func.
Simply putting the tasklet_kill at the start of the function will prevent this
conflict.
Signed-off-by: default avatarMarek Roszko <mark.roszko@gmail.com>
Acked-by: default avatarLeilei Zhao <leilei.zhao@atmel.com>
Cc: <stable@vger.kernel.org> # v3.12
Signed-off-by: default avatarNicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0cc7c6c7
...@@ -2447,11 +2447,12 @@ static int atmel_serial_remove(struct platform_device *pdev) ...@@ -2447,11 +2447,12 @@ static int atmel_serial_remove(struct platform_device *pdev)
struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
int ret = 0; int ret = 0;
tasklet_kill(&atmel_port->tasklet);
device_init_wakeup(&pdev->dev, 0); device_init_wakeup(&pdev->dev, 0);
ret = uart_remove_one_port(&atmel_uart, port); ret = uart_remove_one_port(&atmel_uart, port);
tasklet_kill(&atmel_port->tasklet);
kfree(atmel_port->rx_ring.buf); kfree(atmel_port->rx_ring.buf);
/* "port" is allocated statically, so we shouldn't free it */ /* "port" is allocated statically, so we shouldn't free it */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment