From 03e49d40ea3436cae0fe43708f11584130ee4a0c Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Mon, 6 Jun 2005 15:48:04 -0400 Subject: [PATCH] [PATCH] PCI Hotplug: fix CPCI reference counting bug Here's a patch that fixes up the pci_dev refcounting in the CPCI code. I've done some testing against it and it seems fine here. Signed-off-by: Scott Murray Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/cpci_hotplug_core.c | 2 ++ drivers/pci/hotplug/cpci_hotplug_pci.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c index 8132d946c384..30af105271a2 100644 --- a/drivers/pci/hotplug/cpci_hotplug_core.c +++ b/drivers/pci/hotplug/cpci_hotplug_core.c @@ -217,6 +217,8 @@ static void release_slot(struct hotplug_slot *hotplug_slot) kfree(slot->hotplug_slot->info); kfree(slot->hotplug_slot->name); kfree(slot->hotplug_slot); + if (slot->dev) + pci_dev_put(slot->dev); kfree(slot); } diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c index c878028ad215..225b5e551dd6 100644 --- a/drivers/pci/hotplug/cpci_hotplug_pci.c +++ b/drivers/pci/hotplug/cpci_hotplug_pci.c @@ -315,9 +315,12 @@ int cpci_unconfigure_slot(struct slot* slot) PCI_DEVFN(PCI_SLOT(slot->devfn), i)); if (dev) { pci_remove_bus_device(dev); - slot->dev = NULL; + pci_dev_put(dev); } } + pci_dev_put(slot->dev); + slot->dev = NULL; + dbg("%s - exit", __FUNCTION__); return 0; }