[Xenial][PATCH] UBUNTU: SAUCE: Bluetooth: decrease refcount after use

jesse.sung at canonical.com jesse.sung at canonical.com
Mon Nov 14 14:39:23 UTC 2016


From: Wen-chien Jesse Sung <jesse.sung at canonical.com>

BugLink: https://launchpad.net/bugs/1641569

pci_get_subsys() will increase pci device refcount if it finds a
match. Explicitly decrease refcount if a device is found.

Signed-off-by: Wen-chien Jesse Sung <jesse.sung at canonical.com>
---
 drivers/bluetooth/btusb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 842cf10..e7e5ced 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2975,9 +2975,13 @@ static int btusb_probe(struct usb_interface *intf,
 	}
 
 	if (id->driver_info & BTUSB_MARVELL) {
+		struct pci_dev *pdev;
 		hdev->set_bdaddr = btusb_set_bdaddr_marvell;
-		if (pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, 0x1028, 0x0720, NULL) ||
-			pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, 0x1028, 0x0733, NULL)) {
+		pdev = pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, 0x1028, 0x0720, NULL);
+		if (!pdev)
+			pdev = pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, 0x1028, 0x0733, NULL);
+		if (pdev) {
+			pci_dev_put(pdev);
 			hdev->post_open = btusb_edge_post_open;
 			hdev->shutdown = btusb_edge_shutdown;
 		}
-- 
2.7.4





More information about the kernel-team mailing list