Commit 8f7f956d authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

of: fdt: add missing allocation-failure check

commit 49e67dd1 upstream.

The memory allocator passed to __unflatten_device_tree() (e.g. a wrapped
kzalloc) can fail so add the missing sanity check to avoid dereferencing
a NULL pointer.

Fixes: fe140423 ("of/flattree: Refactor unflatten_device_tree and add fdt_unflatten_tree")
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3829ab9f
...@@ -380,6 +380,9 @@ static void __unflatten_device_tree(void *blob, ...@@ -380,6 +380,9 @@ static void __unflatten_device_tree(void *blob,
/* Allocate memory for the expanded device tree */ /* Allocate memory for the expanded device tree */
mem = dt_alloc(size + 4, __alignof__(struct device_node)); mem = dt_alloc(size + 4, __alignof__(struct device_node));
if (!mem)
return;
memset(mem, 0, size); memset(mem, 0, size);
*(__be32 *)(mem + size) = cpu_to_be32(0xdeadbeef); *(__be32 *)(mem + size) = cpu_to_be32(0xdeadbeef);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment