* [PATCH] of: fdt: add missing allocation-failure check
@ 2017-05-17 15:29 Johan Hovold
2017-05-17 16:37 ` Rob Herring
0 siblings, 1 reply; 2+ messages in thread
From: Johan Hovold @ 2017-05-17 15:29 UTC (permalink / raw)
To: Rob Herring, Frank Rowand; +Cc: devicetree, linux-kernel, Johan Hovold, stable
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>
---
drivers/of/fdt.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 3080d9dd031d..43bd69dceabf 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -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);
--
2.13.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] of: fdt: add missing allocation-failure check
2017-05-17 15:29 [PATCH] of: fdt: add missing allocation-failure check Johan Hovold
@ 2017-05-17 16:37 ` Rob Herring
0 siblings, 0 replies; 2+ messages in thread
From: Rob Herring @ 2017-05-17 16:37 UTC (permalink / raw)
To: Johan Hovold; +Cc: Frank Rowand, devicetree, linux-kernel, stable
On Wed, May 17, 2017 at 05:29:09PM +0200, Johan Hovold wrote:
> 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>
> ---
> drivers/of/fdt.c | 3 +++
> 1 file changed, 3 insertions(+)
Applied, thanks.
Rob
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-17 16:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-17 15:29 [PATCH] of: fdt: add missing allocation-failure check Johan Hovold
2017-05-17 16:37 ` Rob Herring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).