Patch "serial: pch: Fix PCI device refcount leak in pch_request_dma()" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    serial: pch: Fix PCI device refcount leak in pch_request_dma()

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     serial-pch-fix-pci-device-refcount-leak-in-pch_reque.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 0125f79b3faa8ce17f35a4ebf814e813b522e4fd
Author: Xiongfeng Wang <wangxiongfeng2@xxxxxxxxxx>
Date:   Tue Nov 22 19:45:59 2022 +0800

    serial: pch: Fix PCI device refcount leak in pch_request_dma()
    
    [ Upstream commit 8be3a7bf773700534a6e8f87f6ed2ed111254be5 ]
    
    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: 3c6a483275f4 ("Serial: EG20T: add PCH_UART driver")
    Signed-off-by: Xiongfeng Wang <wangxiongfeng2@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221122114559.27692-1-wangxiongfeng2@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 8a9065e4a903..ec501c3ce033 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -694,6 +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;
 	}
 	priv->chan_tx = chan;
@@ -710,6 +711,7 @@ static void pch_request_dma(struct uart_port *port)
 			__func__);
 		dma_release_channel(priv->chan_tx);
 		priv->chan_tx = NULL;
+		pci_dev_put(dma_dev);
 		return;
 	}
 
@@ -717,6 +719,8 @@ static void pch_request_dma(struct uart_port *port)
 	priv->rx_buf_virt = dma_alloc_coherent(port->dev, port->fifosize,
 				    &priv->rx_buf_dma, GFP_KERNEL);
 	priv->chan_rx = chan;
+
+	pci_dev_put(dma_dev);
 }
 
 static void pch_dma_rx_complete(void *arg)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux