Skip to contentSkip to conversation

of/fdt: Fix EARLY_FLATTREE crash with no DTB

PATCH New Phil Elwell 1 participant 1 message Oct 23, 2014 Device tree

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 of/fdt: Fix EARLY_FLATTREE crash with no DTB

of_flat_dt_debugfs_export_fdt uses initial_boot_params without checking if it is valid, and ends up dereferencing a NULL pointer if there is no DT blob.

This patch adds a check that initial_boot_params is NULL, returning -ENOENT if it is.

---
 drivers/of/fdt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/of/fdt.c +5 -1
index d1ffca8..f018e5b 100644
@@ -1085,8 +1085,12 @@ static struct debugfs_blob_wrapper flat_dt_blob;
 
 static int __init of_flat_dt_debugfs_export_fdt(void)
 {
-    struct dentry *d = debugfs_create_dir("device-tree", NULL);
+    struct dentry *d;
 
+    if (!initial_boot_params)
+        return -ENOENT;
+
+    d = debugfs_create_dir("device-tree", NULL);
     if (!d)
         return -ENOENT;
 
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html