From cc51dbdf0e254094c2494cfec8a1d46a770e70dd Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 15 Nov 2010 09:32:57 +0000 Subject: [PATCH] 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. Signed-off-by: Jiri Slaby Cc: Konrad Rzeszutek Wilk Cc: Jesse Barnes From: Jiri Slaby 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. Signed-off-by: Jiri Slaby Cc: Milton Miller Signed-off-by: Jan Beulich --- drivers/xen/pcifront/pci_op.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/xen/pcifront/pci_op.c b/drivers/xen/pcifront/pci_op.c index b1fc6b3c..474a1322 100644 --- a/drivers/xen/pcifront/pci_op.c +++ b/drivers/xen/pcifront/pci_op.c @@ -592,9 +592,9 @@ static pci_ers_result_t pcifront_common_process( int cmd, struct pcifront_device 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; -- 2.39.5