serial: pch: Fix PCI device refcount leak in pch_request_dma()
authorXiongfeng Wang <wangxiongfeng2@huawei.com>
Tue, 22 Nov 2022 11:45:59 +0000 (19:45 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 08:26:23 +0000 (09:26 +0100)
commit56e5a7c5ee3f0dc8978b5df2b1a98a1b060c5e2a
treef7212bef7a5c3845974a9a093f2b7dd0c68814cd
parenta4ea20ab82aa2b197dc7b08f51e1d615578276a0
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@huawei.com>
Link: https://lore.kernel.org/r/20221122114559.27692-1-wangxiongfeng2@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tty/serial/pch_uart.c