提交 3bbfd319 编写于 作者: F Feilong Lin 提交者: Bjorn Helgaas

ACPI / hotplug / PCI: Fix reference count leak in enable_slot()

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.comSigned-off-by: NFeilong Lin <linfeilong@huawei.com>
Signed-off-by: NZhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 a38fd874
...@@ -533,6 +533,7 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge) ...@@ -533,6 +533,7 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge)
slot->flags &= ~SLOT_ENABLED; slot->flags &= ~SLOT_ENABLED;
continue; continue;
} }
pci_dev_put(dev);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册