PCI: fix an oops in some pci devices on hotplug remove when their resources are being freed.

Greg KH
2005-04-02T00:08:12Z

ChangeSet 1.2181.16.7, 2005/03/17 10:30:46-08:00, gregkh@suse.de

PCI: fix an oops in some pci devices on hotplug remove when their resources are being freed.

As reported by Prarit Bhargava <prarit@sgi.com>

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

drivers/pci/remove.c | 2 +-
kernel/resource.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)

diff -Nru a/drivers/pci/remove.c b/drivers/pci/remove.c
--- a/drivers/pci/remove.c 2005-04-01 15:37:58 -08:00
+++ b/drivers/pci/remove.c 2005-04-01 15:37:58 -08:00
@@ -19,7 +19,7 @@
pci_cleanup_rom(dev);
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
struct resource *res = dev->resource + i;
- if (res->parent)
+ if (res && res->parent)
release_resource(res);
}
}
diff -Nru a/kernel/resource.c b/kernel/resource.c
--- a/kernel/resource.c 2005-04-01 15:37:58 -08:00
+++ b/kernel/resource.c 2005-04-01 15:37:58 -08:00
@@ -505,6 +505,7 @@
*p = res->sibling;
write_unlock(&resource_lock);
kfree(res);
+ res = NULL;
return;
}
p = &res->sibling;