[coreboot] [PATCH] v3: Fix two NULL pointer dereferences in device code
Carl-Daniel Hailfinger
c-d.hailfinger.devel.2006 at gmx.net
Wed Mar 5 03:03:46 CET 2008
Ron? You can probably tell if bus->dev==NULL in read_resources(bus)
is an error or if we need to handle it cleanly.
Fix two NULL pointer dereferences in device code.
Add a nasty warning if one of the cases triggers because that should
not happen. We should fix the cases where the warning triggers.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
Index: LinuxBIOSv3-db800-forexport/device/device.c
===================================================================
--- LinuxBIOSv3-db800-forexport/device/device.c (Revision 630)
+++ LinuxBIOSv3-db800-forexport/device/device.c (Arbeitskopie)
@@ -278,8 +278,13 @@
struct device *curdev;
printk(BIOS_SPEW, "%s: %s(%s) read_resources bus %d link: %d\n",
- __func__, bus->dev->dtsname, dev_path(bus->dev),
+ __func__,
+ (bus->dev ? bus->dev->dtsname : "No dtsname for NULL device"),
+ (bus->dev ? dev_path(bus->dev) : "No path for NULL device"),
bus->secondary, bus->link);
+ if (!bus->dev)
+ printk(BIOS_WARNING, "%s: ERROR: bus->dev is NULL!\n",
+ __func__);
/* Walk through all devices and find which resources they need. */
for (curdev = bus->children; curdev; curdev = curdev->sibling) {
Index: LinuxBIOSv3-db800-forexport/device/pci_device.c
===================================================================
--- LinuxBIOSv3-db800-forexport/device/pci_device.c (Revision 630)
+++ LinuxBIOSv3-db800-forexport/device/pci_device.c (Arbeitskopie)
@@ -1101,7 +1101,7 @@
dev = pci_probe_dev(dev, bus, devfn);
printk(BIOS_SPEW,
"PCI: pci_scan_bus pci_probe_dev returns dev %p(%s)\n",
- dev, dev->dtsname);
+ dev, dev ? dev->dtsname : "None (not found)");
/* If this is not a multi function device, or the device is
* not present don't waste time probing another function.
--
http://www.hailfinger.org/
More information about the coreboot
mailing list