From: Jiri Slaby Date: Thu, 4 Nov 2010 14:31:30 +0000 (+0100) Subject: xen-pcifront: fix PCI reference leak X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2a63dd7275b2278bd7e9203f74b9aa4f07e82a7a;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git xen-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. [v2: Updated to not dereference pcidev->dev per Milton's observation] Signed-off-by: Jiri Slaby Signed-off-by: Konrad Rzeszutek Wilk Cc: Milton Miller Cc: Jesse Barnes --- diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index 05792732718e..3a5a6fcc0ead 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c @@ -575,8 +575,9 @@ static pci_ers_result_t pcifront_common_process(int cmd, pcidev = pci_get_bus_and_slot(bus, devfn); if (!pcidev || !pcidev->driver) { - dev_err(&pcidev->dev, - "device or driver is NULL\n"); + dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n"); + if (pcidev) + pci_dev_put(pcidev); return result; } pdrv = pcidev->driver;