Skip to content

Commit 8be3a7b

Browse files
fenghusthugregkh
authored andcommitted
serial: pch: Fix PCI device refcount leak in pch_request_dma()
As comment of pci_get_slot() says, it returns a pci_device with its refcount increased. The caller must decrement the reference count by calling pci_dev_put(). Since 'dma_dev' is only used to filter the channel in filter(), we can call pci_dev_put() before exiting from pch_request_dma(). Add the missing pci_dev_put() for the normal and error path. Fixes: 3c6a483 ("Serial: EG20T: add PCH_UART driver") Signed-off-by: Xiongfeng Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 22cf92b commit 8be3a7b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/tty/serial/pch_uart.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ static void pch_request_dma(struct uart_port *port)
694694
if (!chan) {
695695
dev_err(priv->port.dev, "%s:dma_request_channel FAILS(Tx)\n",
696696
__func__);
697+
pci_dev_put(dma_dev);
697698
return;
698699
}
699700
priv->chan_tx = chan;
@@ -710,13 +711,16 @@ static void pch_request_dma(struct uart_port *port)
710711
__func__);
711712
dma_release_channel(priv->chan_tx);
712713
priv->chan_tx = NULL;
714+
pci_dev_put(dma_dev);
713715
return;
714716
}
715717

716718
/* Get Consistent memory for DMA */
717719
priv->rx_buf_virt = dma_alloc_coherent(port->dev, port->fifosize,
718720
&priv->rx_buf_dma, GFP_KERNEL);
719721
priv->chan_rx = chan;
722+
723+
pci_dev_put(dma_dev);
720724
}
721725

722726
static void pch_dma_rx_complete(void *arg)

0 commit comments

Comments
 (0)