Commit 1be6f2b
tty: serial: fsl_lpuart: fix race on RX DMA shutdown
From time to time DMA completion can come in the middle of DMA shutdown:
<process ctx>: <IRQ>:
lpuart32_shutdown()
lpuart_dma_shutdown()
del_timer_sync()
lpuart_dma_rx_complete()
lpuart_copy_rx_to_tty()
mod_timer()
lpuart_dma_rx_free()
When the timer fires a bit later, sport->dma_rx_desc is NULL:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000004
pc : lpuart_copy_rx_to_tty+0xcc/0x5bc
lr : lpuart_timer_func+0x1c/0x2c
Call trace:
lpuart_copy_rx_to_tty
lpuart_timer_func
call_timer_fn
__run_timers.part.0
run_timer_softirq
__do_softirq
__irq_exit_rcu
irq_exit
handle_domain_irq
gic_handle_irq
call_on_irq_stack
do_interrupt_handler
...
To fix this fold del_timer_sync() into lpuart_dma_rx_free() after
dmaengine_terminate_sync() to make sure timer will not be re-started in
lpuart_copy_rx_to_tty() <= lpuart_dma_rx_complete().
Fixes: 4a8588a ("serial: fsl_lpuart: delete timer on shutdown")
Cc: stable <stable@kernel.org>
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Link: https://lore.kernel.org/r/20230309134302.74940-2-alexander.sverdlin@siemens.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 5d943b5 commit 1be6f2b
1 file changed
Lines changed: 3 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1354 | 1354 | | |
1355 | 1355 | | |
1356 | 1356 | | |
| 1357 | + | |
1357 | 1358 | | |
1358 | 1359 | | |
1359 | 1360 | | |
| |||
1813 | 1814 | | |
1814 | 1815 | | |
1815 | 1816 | | |
1816 | | - | |
1817 | 1817 | | |
1818 | 1818 | | |
1819 | 1819 | | |
| |||
1973 | 1973 | | |
1974 | 1974 | | |
1975 | 1975 | | |
1976 | | - | |
1977 | | - | |
| 1976 | + | |
1978 | 1977 | | |
1979 | | - | |
1980 | 1978 | | |
1981 | 1979 | | |
1982 | 1980 | | |
| |||
2210 | 2208 | | |
2211 | 2209 | | |
2212 | 2210 | | |
2213 | | - | |
2214 | | - | |
| 2211 | + | |
2215 | 2212 | | |
2216 | | - | |
2217 | 2213 | | |
2218 | 2214 | | |
2219 | 2215 | | |
| |||
3020 | 3016 | | |
3021 | 3017 | | |
3022 | 3018 | | |
3023 | | - | |
3024 | 3019 | | |
3025 | 3020 | | |
3026 | 3021 | | |
| |||
0 commit comments