diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2013-01-29 18:44:27 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-02-03 20:55:29 -0500 |
commit | 4fa3e78be7e985ca814ce2aa0c09cbee404efcf7 (patch) | |
tree | 5afeff2353b3c6c1fd9ebad53c24ca8efcfe5371 | |
parent | 422d26b6ecd77af8c77f2a40580679459825170f (diff) |
Driver core: treat unregistered bus_types as having no devices
A bus_type has a list of devices (klist_devices), but the list and the
subsys_private structure that contains it are not initialized until the
bus_type is registered with bus_register().
The panic/reboot path has fixups that look up devices in pci_bus_type. If
we panic before registering pci_bus_type, the bus_type exists but the list
does not, so mach_reboot_fixups() trips over a null pointer and panics
again:
mach_reboot_fixups
pci_get_device
..
bus_find_device(&pci_bus_type, ...)
bus->p is NULL
Joonsoo reported a problem when panicking before PCI was initialized.
I think this patch should be sufficient to replace the patch he posted
here: https://lkml.org/lkml/2012/12/28/75 ("[PATCH] x86, reboot: skip
reboot_fixups in early boot phase")
Reported-by: Joonsoo Kim <js1304@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/base/bus.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index f9d31320bd37..519865b53f76 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -290,7 +290,7 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start, | |||
290 | struct device *dev; | 290 | struct device *dev; |
291 | int error = 0; | 291 | int error = 0; |
292 | 292 | ||
293 | if (!bus) | 293 | if (!bus || !bus->p) |
294 | return -EINVAL; | 294 | return -EINVAL; |
295 | 295 | ||
296 | klist_iter_init_node(&bus->p->klist_devices, &i, | 296 | klist_iter_init_node(&bus->p->klist_devices, &i, |
@@ -324,7 +324,7 @@ struct device *bus_find_device(struct bus_type *bus, | |||
324 | struct klist_iter i; | 324 | struct klist_iter i; |
325 | struct device *dev; | 325 | struct device *dev; |
326 | 326 | ||
327 | if (!bus) | 327 | if (!bus || !bus->p) |
328 | return NULL; | 328 | return NULL; |
329 | 329 | ||
330 | klist_iter_init_node(&bus->p->klist_devices, &i, | 330 | klist_iter_init_node(&bus->p->klist_devices, &i, |