diff options
author | Johan Hovold <johan@kernel.org> | 2017-05-17 18:29:09 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-25 16:44:37 +0300 |
commit | 9907c838fc0700de8a614587cc58490c54fd4551 (patch) | |
tree | 204eb85314bbff2cc5cf772846562844122cbef5 /drivers/of | |
parent | 80cdf2065bf0e10862b400715672555ef3e49a3e (diff) | |
download | linux-9907c838fc0700de8a614587cc58490c54fd4551.tar.xz |
of: fdt: add missing allocation-failure check
commit 49e67dd17649b60b4d54966e18ec9c80198227f0 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: fe14042358fa ("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>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/fdt.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index c89d5d231a0e..6a43fd3d0576 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -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); |