mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
of: fdt: add missing allocation-failure check
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")
Cc: stable <[email protected]> # 2.6.38
Signed-off-by: Johan Hovold <[email protected]>
Signed-off-by: Rob Herring <[email protected]>
This commit is contained in:
parent
828d4cdd01
commit
49e67dd176
1 changed files with 3 additions and 0 deletions
|
|
@ -507,6 +507,9 @@ 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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue