mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
of: fdt: add missing allocation-failure check
commit49e67dd176upstream. 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:fe14042358("of/flattree: Refactor unflatten_device_tree and add fdt_unflatten_tree") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
80cdf2065b
commit
9907c838fc
@@ -505,6 +505,9 @@ static void *__unflatten_device_tree(const void *blob,
|
||||
|
||||
/* Allocate memory for the expanded device tree */
|
||||
mem = dt_alloc(size + 4, __alignof__(struct device_node));
|
||||
if (!mem)
|
||||
return NULL;
|
||||
|
||||
memset(mem, 0, size);
|
||||
|
||||
*(__be32 *)(mem + size) = cpu_to_be32(0xdeadbeef);
|
||||
|
||||
Reference in New Issue
Block a user