of: fdt: add missing allocation-failure check
Subsystems (2)
PATCH 1/1 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 fe14042358fa ("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]>
--- drivers/of/fdt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/of/fdt.c +3 -0
@@ -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 );
Signature · 6 lines
2.13.0 -- 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
Quoted 10 lines · Johan Hovold
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 fe14042358fa ("of/flattree: Refactor unflatten_device_tree and add fdt_unflatten_tree")Cc stable <[email protected]> # 2.6.38Signed-off-by Johan Hovold <[email protected]>--- drivers/of/fdt.c | 3 +++ 1 file changed, 3 insertions(+)
Applied, thanks.
Rob