[PATCH] PCI Hotplug: fix CPCI reference counting bug

From: Greg KH
Date: Thu Jun 09 2005 - 11:53:33 EST


[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 <scottm@xxxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
commit 03e49d40ea3436cae0fe43708f11584130ee4a0c
tree acaa11b11c0ff1d4c9f743c0d8df2bc5a865a440
parent 5273a00d9c763108397658d440618f7ac3e40f83
author Scott Murray <scottm@xxxxxxxxxxxxxxxx> Mon, 06 Jun 2005 15:48:04 -0400
committer Greg Kroah-Hartman <gregkh@xxxxxxx> Thu, 09 Jun 2005 01:37:59 -0700

drivers/pci/hotplug/cpci_hotplug_core.c | 2 ++
drivers/pci/hotplug/cpci_hotplug_pci.c | 5 ++++-
2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
--- 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_
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
--- 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* s
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;
}
scottm@xxxxxxxxxxxxxxxx
[PATCH] PCI Hotplug: fix CPCI reference counting bug
[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 <scottm@xxxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
commit 03e49d40ea3436cae0fe43708f11584130ee4a0c
tree acaa11b11c0ff1d4c9f743c0d8df2bc5a865a440
parent 5273a00d9c763108397658d440618f7ac3e40f83
author Scott Murray <scottm@xxxxxxxxxxxxxxxx> Mon, 06 Jun 2005 15:48:04 -0400
committer Greg Kroah-Hartman <gregkh@xxxxxxx> Thu, 09 Jun 2005 01:37:59 -0700

drivers/pci/hotplug/cpci_hotplug_core.c | 2 ++
drivers/pci/hotplug/cpci_hotplug_pci.c | 5 ++++-
2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
--- 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_
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
--- 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* s
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;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/