mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-07-30 16:18:14 +02:00
tty: serial: pch_uart: add check for dma_alloc_coherent()
commit6fe472c1bbupstream. Add a check for dma_alloc_coherent() failure to prevent a potential NULL pointer dereference in dma_handle_rx(). Properly release DMA channels and the PCI device reference using a goto ladder if the allocation fails. Fixes:3c6a483275("Serial: EG20T: add PCH_UART driver") Cc: stable <stable@kernel.org> Signed-off-by: Zhaoyang Yu <2426767509@qq.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/tencent_E328416B7CFD436F6029F2DF02AD7ED89C08@qq.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c8a70b5af8
commit
daea997bb2
@@ -694,8 +694,7 @@ static void pch_request_dma(struct uart_port *port)
|
||||
if (!chan) {
|
||||
dev_err(priv->port.dev, "%s:dma_request_channel FAILS(Tx)\n",
|
||||
__func__);
|
||||
pci_dev_put(dma_dev);
|
||||
return;
|
||||
goto err_pci_get;
|
||||
}
|
||||
priv->chan_tx = chan;
|
||||
|
||||
@@ -709,18 +708,26 @@ static void pch_request_dma(struct uart_port *port)
|
||||
if (!chan) {
|
||||
dev_err(priv->port.dev, "%s:dma_request_channel FAILS(Rx)\n",
|
||||
__func__);
|
||||
dma_release_channel(priv->chan_tx);
|
||||
priv->chan_tx = NULL;
|
||||
pci_dev_put(dma_dev);
|
||||
return;
|
||||
goto err_req_tx;
|
||||
}
|
||||
|
||||
/* Get Consistent memory for DMA */
|
||||
priv->rx_buf_virt = dma_alloc_coherent(port->dev, port->fifosize,
|
||||
&priv->rx_buf_dma, GFP_KERNEL);
|
||||
if (!priv->rx_buf_virt)
|
||||
goto err_req_rx;
|
||||
priv->chan_rx = chan;
|
||||
|
||||
pci_dev_put(dma_dev);
|
||||
return;
|
||||
|
||||
err_req_rx:
|
||||
dma_release_channel(chan);
|
||||
err_req_tx:
|
||||
dma_release_channel(priv->chan_tx);
|
||||
priv->chan_tx = NULL;
|
||||
err_pci_get:
|
||||
pci_dev_put(dma_dev);
|
||||
}
|
||||
|
||||
static void pch_dma_rx_complete(void *arg)
|
||||
|
||||
Reference in New Issue
Block a user