Skip to content

Commit f50c995

Browse files
marekrgregkh
authored andcommitted
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: Marek Roszko <mark.roszko@gmail.com> Acked-by: Leilei Zhao <leilei.zhao@atmel.com> Cc: <stable@vger.kernel.org> # v3.12 Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0cc7c6c commit f50c995

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/tty/serial/atmel_serial.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2447,11 +2447,12 @@ static int atmel_serial_remove(struct platform_device *pdev)
24472447
struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
24482448
int ret = 0;
24492449

2450+
tasklet_kill(&atmel_port->tasklet);
2451+
24502452
device_init_wakeup(&pdev->dev, 0);
24512453

24522454
ret = uart_remove_one_port(&atmel_uart, port);
24532455

2454-
tasklet_kill(&atmel_port->tasklet);
24552456
kfree(atmel_port->rx_ring.buf);
24562457

24572458
/* "port" is allocated statically, so we shouldn't free it */

0 commit comments

Comments
 (0)