]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
ACPI / hotplug / PCI: Fix reference count leak in enable_slot()
authorFeilong Lin <linfeilong@huawei.com>
Thu, 25 Mar 2021 07:26:00 +0000 (15:26 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 30 Jun 2021 06:26:47 +0000 (08:26 +0200)
BugLink: https://bugs.launchpad.net/bugs/1931896
[ Upstream commit 3bbfd319034ddce59e023837a4aa11439460509b ]

In enable_slot(), if pci_get_slot() returns NULL, we clear the SLOT_ENABLED
flag. When pci_get_slot() finds a device, it increments the device's
reference count.  In this case, we did not call pci_dev_put() to decrement
the reference count, so the memory of the device (struct pci_dev type) will
eventually leak.

Call pci_dev_put() to decrement its reference count when pci_get_slot()
returns a PCI device.

Link: https://lore.kernel.org/r/b411af88-5049-a1c6-83ac-d104a1f429be@huawei.com
Signed-off-by: Feilong Lin <linfeilong@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
drivers/pci/hotplug/acpiphp_glue.c

index 3365c93abf0e2e08e44a3e547f8b6a51ed0d654d..f031302ad4019b5c2d783cb713102e5214bcd578 100644 (file)
@@ -533,6 +533,7 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge)
                        slot->flags &= ~SLOT_ENABLED;
                        continue;
                }
+               pci_dev_put(dev);
        }
 }