Skip to content

Commit 90f04c2

Browse files
Tomoya MORINAGAgregkh
authored andcommitted
pch_uart: Fix DMA resource leak issue
Changing UART mode PIO->DMA->PIO->DMA like below, pch_uart driver can't get DMA channel resource. setserial /dev/ttyPCH0 ^low_latency setserial /dev/ttyPCH0 low_latency CAUSE: Changing mode using setserial command, ".startup" function which gets DMA channel is called before ".verify_port" function which sets dma-flag(use_dma/use_dma_flag) as 1. PIO->DMA .startup: Since dma-flag is 0, DMA channel is not requested. .verify_port: dma-flag is set as 1. .shutdown: N/A DMA->PIO .startup: Since dma-flag is 1, DMA channel is requested. .verify_port: dma-flag is set as 0. .shutdown: Since dma-flag is 0, DMA channel is not released. This means DMA channel resource leak occurs. Next time, this driver can't get DMA channel resource forever. MODIFICATION: Currently, when release DMA channel resource, this driver checks dma-flag. However, this specification occurs the above issue. This driver must check whether dma_request_channel is executed or not. The values are saved in private data variable "chan_tx/chan_tx". These variables mean if the value is NULL, DMA channel is not requested, if not NULL, DMA channel is requested. This patch fixes the issue. Signed-off-by: Tomoya MORINAGA <[email protected]> Acked-by: Alan Cox <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 604fdb7 commit 90f04c2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/tty/serial/pch_uart.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ static void pch_request_dma(struct uart_port *port)
632632
dev_err(priv->port.dev, "%s:dma_request_channel FAILS(Rx)\n",
633633
__func__);
634634
dma_release_channel(priv->chan_tx);
635+
priv->chan_tx = NULL;
635636
return;
636637
}
637638

@@ -1219,8 +1220,7 @@ static void pch_uart_shutdown(struct uart_port *port)
12191220
dev_err(priv->port.dev,
12201221
"pch_uart_hal_set_fifo Failed(ret=%d)\n", ret);
12211222

1222-
if (priv->use_dma_flag)
1223-
pch_free_dma(port);
1223+
pch_free_dma(port);
12241224

12251225
free_irq(priv->port.irq, priv);
12261226
}

0 commit comments

Comments
 (0)