[coreboot] [PATCH] v3: Add build time warning for NULL dereference

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Thu Mar 20 04:00:21 CET 2008

Since I didn't get an answer about whether it is legal to have
bus->dev == NULL, simply add a build time warning because we
will dereference a NULL pointer at runtime on some targets.
If bus->dev == NULL is illegal, we'll have to add some checks
and a hefty warning to the code.

I admit I was tempted to make this an #error just to have someone
look at the problem more closely.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

Index: LinuxBIOSv3-stuff/device/device.c
--- LinuxBIOSv3-stuff/device/device.c	(Revision 644)
+++ LinuxBIOSv3-stuff/device/device.c	(Arbeitskopie)
@@ -290,6 +290,7 @@
 	for (curdev = bus->children; curdev; curdev = curdev->sibling) {
 		unsigned int links;
 		int i;
+#warning Missing NULL check, will explode at runtime
 		       "%s: %s(%s) dtsname %s have_resources %d enabled %d\n",
 		       __func__, bus->dev->dtsname, dev_path(bus->dev),


More information about the coreboot mailing list