Fix one NULL pointer dereference, add code to debug another one.
Don't commit yet, I'd rather apply a fix for the NULL pointer than just debugging it.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: device/device.c =================================================================== --- device/device.c (Revision 630) +++ device/device.c (Arbeitskopie) @@ -277,8 +277,9 @@ { struct device *curdev;
- printk(BIOS_SPEW, "%s: %s(%s) read_resources bus %d link: %d\n", - __func__, bus->dev->dtsname, dev_path(bus->dev), + printk(BIOS_SPEW, "%s: bus->dev %p, bus->dev->dtsname %p, %s(%s) read_resources bus %d link: %d\n", + __func__, bus->dev, bus->dev->dtsname, + bus->dev->dtsname, dev_path(bus->dev), bus->secondary, bus->link);
/* Walk through all devices and find which resources they need. */ Index: device/pci_device.c =================================================================== --- device/pci_device.c (Revision 630) +++ 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.
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@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.
Acked-by: Ronald G. Minnich rminnich@gmail.com
This was on db800 right? I need to get a failure case.
On 05.03.2008 03:54, ron minnich wrote:
Acked-by: Ronald G. Minnich rminnich@gmail.com
Thanks, committed in r631.
This was on db800 right? I need to get a failure case.
db800, norwich, probably any AMD board triggered the NULL dereference in device/device.c. There is still one NULL dereference left in device/device.c and I need you to answer my question to fix it completely. Then again, you probably asked for a way to reproduce to see this. With the patch applied, look for "ERROR: bus->dev is NULL" in the logs and notice if that appears, there is garbage in the log later on.
Ron? You can probably tell if bus->dev==NULL in read_resources(bus) is an error or if we need to handle it cleanly.
All boards (including qemu) triggered the NULL pointer in device/pci_device.c. Look for "None (not found)" in the logs with the patch applied. You'll see it 33 times in the qemu boot log.
Regards, Carl-Daniel