diff options
author | Johan Hovold <johan@kernel.org> | 2017-05-17 17:29:09 +0200 |
---|---|---|
committer | Sasha Levin <alexander.levin@verizon.com> | 2017-06-08 06:12:46 -0400 |
commit | 78de28c67c8f3e46d4198982cff389ab986544ac (patch) | |
tree | 707b5d210e65d6a5c2eaf1406156559f7945fd61 /drivers/of | |
parent | ac38837324c2f0b818892abfefbf26593edf1d62 (diff) |
of: fdt: add missing allocation-failure check
[ Upstream commit 49e67dd17649b60b4d54966e18ec9c80198227f0 ]
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 <stable@vger.kernel.org> # 2.6.38
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
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 d91f721a05b6..63ea1e5b1c95 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -412,6 +412,9 @@ static void __unflatten_device_tree(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); |