[PATCH] usb: cdns3: cdnsp-pci: Fix PCI function reference leak in cdnsp_pci_probe()

Wentao Liang posted 1 patch 1 week ago
drivers/usb/cdns3/cdnsp-pci.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] usb: cdns3: cdnsp-pci: Fix PCI function reference leak in cdnsp_pci_probe()
Posted by Wentao Liang 1 week ago
cdnsp_get_second_fun() returns a device obtained with pci_get_device(),
which takes a reference to it. The error paths release it through the
put_pci label, but the successful return does not, so the reference is
leaked for every successfully probed device.

Release it on the success path too.

Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/usb/cdns3/cdnsp-pci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/cdns3/cdnsp-pci.c b/drivers/usb/cdns3/cdnsp-pci.c
index 566d94e49102..061a2c43e986 100644
--- a/drivers/usb/cdns3/cdnsp-pci.c
+++ b/drivers/usb/cdns3/cdnsp-pci.c
@@ -162,6 +162,8 @@ static int cdnsp_pci_probe(struct pci_dev *pdev,
 	if (pci_dev_run_wake(pdev))
 		pm_runtime_put_noidle(&pdev->dev);
 
+	pci_dev_put(func);
+
 	return 0;
 
 free_cdnsp:
-- 
2.34.1