* [PATCH] of/flattree: Fix crash when device tree absent
@ 2010-06-25 22:03 Grant Likely
0 siblings, 0 replies; only message in thread
From: Grant Likely @ 2010-06-25 22:03 UTC (permalink / raw)
To: benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r,
monstr-pSz03upnqPeHXe+LvDLADg
Cc: microblaze-uclinux-rVRm/Wmeqae7NGdpmJTKYQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw, sfr-3FnU+UHB4dNDw9hX6IcOSA
This patch fixes the condition where device tree support is compiled
in, but no device tree was proved by firmware. It makes
of_platform_bus_probe() explicitly check for a NULL device tree
pointer, and adds an error message if the device tree was unable
to be flattened.
Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
---
drivers/of/fdt.c | 2 ++
drivers/of/platform.c | 2 ++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index b6987bb..beda593 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -94,6 +94,8 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
break;
} while (1);
+ if (rc)
+ pr_err("Failed to unflatten device tree blob. rc=%i\n", rc);
return rc;
}
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 3eb4cf6..1f5a210 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -640,6 +640,8 @@ int of_platform_bus_probe(struct device_node *root,
root = of_find_node_by_path("/");
else
of_node_get(root);
+ if (root == NULL)
+ return -EINVAL;
pr_debug("of_platform_bus_probe()\n");
pr_debug(" starting at: %s\n", root->full_name);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2010-06-25 22:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-25 22:03 [PATCH] of/flattree: Fix crash when device tree absent Grant Likely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox