Skip to contentSkip to conversation

linux-2.6.18/pcifront: fix PCI reference leak and potential NULL dereference

PATCH New Jan Beulich 1 participant 1 message Nov 11, 2010 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-2.6.18/pcifront: fix PCI reference leak and potential NULL dereference

From: Jiri Slaby <[email protected]>
Subject: pcifront: fix PCI reference leak

Stanse found that when pdev is found and has no driver a reference is leaked in pcifront_common_process. So add pci_dev_put there. For the pdev == NULL case, pci_dev_put(NULL) is fine.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Jesse Barnes <[email protected]>

From: Jiri Slaby <[email protected]>
Subject: pcifront: fix potential NULL dereference

Milton spotted that we dereference NULL in one fail path in pcifront_common_process. Fix that by using different device to print out an error.

Cc Milton Miller <[email protected]>
drivers/xen/pcifront/pci_op.c +3 -3
@@ -592,9 +592,9 @@ static pci_ers_result_t pcifront_common_
 	result = PCI_ERS_RESULT_NONE;
 
 	pcidev = pci_get_bus_and_slot(bus, devfn);
-	if (!pcidev || !pcidev->driver){
-		dev_err(&pcidev->dev, 
-			"device or driver is NULL\n");
+	if (!pcidev || !pcidev->driver) {
+		pci_dev_put(pcidev);
+		dev_err(&pdev->xdev->dev, "AER device or driver is NULL\n");
 		return result;
 	}
 	pdrv = pcidev->driver;

From: Jiri Slaby <[email protected]>
Subject: pcifront: fix PCI reference leak

Stanse found that when pdev is found and has no driver a reference is leaked in pcifront_common_process. So add pci_dev_put there. For the pdev == NULL case, pci_dev_put(NULL) is fine.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Jesse Barnes <[email protected]>

From: Jiri Slaby <[email protected]>
Subject: pcifront: fix potential NULL dereference

Milton spotted that we dereference NULL in one fail path in pcifront_common_process. Fix that by using different device to print out an error.

Cc Milton Miller <[email protected]>
drivers/xen/pcifront/pci_op.c +3 -3
@@ -592,9 +592,9 @@ static pci_ers_result_t pcifront_common_
 	result = PCI_ERS_RESULT_NONE;
 
 	pcidev = pci_get_bus_and_slot(bus, devfn);
-	if (!pcidev || !pcidev->driver){
-		dev_err(&pcidev->dev, 
-			"device or driver is NULL\n");
+	if (!pcidev || !pcidev->driver) {
+		pci_dev_put(pcidev);
+		dev_err(&pdev->xdev->dev, "AER device or driver is NULL\n");
 		return result;
 	}
 	pdrv = pcidev->driver;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel