Skip to content

Commit f661131

Browse files
geertugregkh
authored andcommitted
serial: sh-sci: Stop TX DMA workqueue during port shutdown
The transmit DMA workqueue is never stopped, hence the work function may be called after the port has been shut down. Fix this race condition by cancelling queued work, if any, before DMA release. Don't initialize the work if DMA initialization failed, as it won't be used anyway. Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2c4ee23 commit f661131

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/tty/serial/sh-sci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,7 @@ static void sci_tx_dma_release(struct sci_port *s)
12931293
{
12941294
struct dma_chan *chan = s->chan_tx_saved;
12951295

1296+
cancel_work_sync(&s->work_tx);
12961297
s->chan_tx_saved = s->chan_tx = NULL;
12971298
s->cookie_tx = -EINVAL;
12981299
dmaengine_terminate_all(chan);
@@ -1548,10 +1549,9 @@ static void sci_request_dma(struct uart_port *port)
15481549
__func__, UART_XMIT_SIZE,
15491550
port->state->xmit.buf, &s->tx_dma_addr);
15501551

1552+
INIT_WORK(&s->work_tx, work_fn_tx);
15511553
s->chan_tx_saved = s->chan_tx = chan;
15521554
}
1553-
1554-
INIT_WORK(&s->work_tx, work_fn_tx);
15551555
}
15561556

15571557
chan = sci_request_dma_chan(port, DMA_DEV_TO_MEM);

0 commit comments

Comments
 (0)