Commit 1f1f8d52 authored by John Rose's avatar John Rose Committed by Greg Kroah-Hartman

[PATCH] PCI: fix release_pcibus_dev() crash

During the course of a hotplug removal of a PCI bus, release_pcibus_dev()
attempts to remove attribute files from a kobject directory that no longer
exists.  This patch moves these calls to pci_remove_bus(), where they can work
as intended.
Signed-off-by: default avatarJohn Rose <johnrose@austin.ibm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent bc338cbe
......@@ -59,12 +59,14 @@ struct pci_visit {
extern int pci_visit_dev(struct pci_visit *fn,
struct pci_dev_wrapped *wrapped_dev,
struct pci_bus_wrapped *wrapped_parent);
extern void pci_remove_legacy_files(struct pci_bus *bus);
/* Lock for read/write access to pci device and bus lists */
extern spinlock_t pci_bus_lock;
extern int pcie_mch_quirk;
extern struct device_attribute pci_dev_attrs[];
extern struct class_device_attribute class_device_attr_cpuaffinity;
/**
* pci_match_one_device - Tell if a PCI device structure has a matching
......
......@@ -62,7 +62,7 @@ static void pci_create_legacy_files(struct pci_bus *b)
}
}
static void pci_remove_legacy_files(struct pci_bus *b)
void pci_remove_legacy_files(struct pci_bus *b)
{
class_device_remove_bin_file(&b->class_dev, b->legacy_io);
class_device_remove_bin_file(&b->class_dev, b->legacy_mem);
......@@ -70,7 +70,7 @@ static void pci_remove_legacy_files(struct pci_bus *b)
}
#else /* !HAVE_PCI_LEGACY */
static inline void pci_create_legacy_files(struct pci_bus *bus) { return; }
static inline void pci_remove_legacy_files(struct pci_bus *bus) { return; }
void pci_remove_legacy_files(struct pci_bus *bus) { return; }
#endif /* HAVE_PCI_LEGACY */
/*
......@@ -86,7 +86,7 @@ static ssize_t pci_bus_show_cpuaffinity(struct class_device *class_dev, char *bu
buf[ret++] = '\n';
return ret;
}
static CLASS_DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpuaffinity, NULL);
CLASS_DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpuaffinity, NULL);
/*
* PCI Bus Class
......@@ -95,10 +95,6 @@ static void release_pcibus_dev(struct class_device *class_dev)
{
struct pci_bus *pci_bus = to_pci_bus(class_dev);
pci_remove_legacy_files(pci_bus);
class_device_remove_file(&pci_bus->class_dev,
&class_device_attr_cpuaffinity);
sysfs_remove_link(&pci_bus->class_dev.kobj, "bridge");
if (pci_bus->bridge)
put_device(pci_bus->bridge);
kfree(pci_bus);
......
......@@ -61,15 +61,18 @@ int pci_remove_device_safe(struct pci_dev *dev)
}
EXPORT_SYMBOL(pci_remove_device_safe);
void pci_remove_bus(struct pci_bus *b)
void pci_remove_bus(struct pci_bus *pci_bus)
{
pci_proc_detach_bus(b);
pci_proc_detach_bus(pci_bus);
spin_lock(&pci_bus_lock);
list_del(&b->node);
list_del(&pci_bus->node);
spin_unlock(&pci_bus_lock);
class_device_unregister(&b->class_dev);
pci_remove_legacy_files(pci_bus);
class_device_remove_file(&pci_bus->class_dev,
&class_device_attr_cpuaffinity);
sysfs_remove_link(&pci_bus->class_dev.kobj, "bridge");
class_device_unregister(&pci_bus->class_dev);
}
EXPORT_SYMBOL(pci_remove_bus);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment