* FAILED: patch "[PATCH] of: fdt: add missing allocation-failure check" failed to apply to 4.4-stable tree
@ 2017-05-22 19:17 gregkh
2017-05-22 20:46 ` Rob Herring
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2017-05-22 19:17 UTC (permalink / raw)
To: johan, robh, stable; +Cc: stable
The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
>From 49e67dd17649b60b4d54966e18ec9c80198227f0 Mon Sep 17 00:00:00 2001
From: Johan Hovold <johan@kernel.org>
Date: Wed, 17 May 2017 17:29:09 +0200
Subject: [PATCH] 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 <stable@vger.kernel.org> # 2.6.38
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index a0972219ccfc..0373ae49d24d 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);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: FAILED: patch "[PATCH] of: fdt: add missing allocation-failure check" failed to apply to 4.4-stable tree
2017-05-22 19:17 FAILED: patch "[PATCH] of: fdt: add missing allocation-failure check" failed to apply to 4.4-stable tree gregkh
@ 2017-05-22 20:46 ` Rob Herring
2017-05-23 9:16 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Rob Herring @ 2017-05-22 20:46 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Johan Hovold, stable
On Mon, May 22, 2017 at 2:17 PM, <gregkh@linuxfoundation.org> wrote:
>
> The patch below does not apply to the 4.4-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
>
> thanks,
>
> greg k-h
>
> ------------------ original commit in Linus's tree ------------------
>
> From 49e67dd17649b60b4d54966e18ec9c80198227f0 Mon Sep 17 00:00:00 2001
> From: Johan Hovold <johan@kernel.org>
> Date: Wed, 17 May 2017 17:29:09 +0200
> Subject: [PATCH] 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 <stable@vger.kernel.org> # 2.6.38
> Signed-off-by: Johan Hovold <johan@kernel.org>
> Signed-off-by: Rob Herring <robh@kernel.org>
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index a0972219ccfc..0373ae49d24d 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -507,6 +507,9 @@ void *__unflatten_device_tree(const void *blob,
The context looks the same, it's just the line number is 416 in v4.4.
>
> /* 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);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: FAILED: patch "[PATCH] of: fdt: add missing allocation-failure check" failed to apply to 4.4-stable tree
2017-05-22 20:46 ` Rob Herring
@ 2017-05-23 9:16 ` Greg Kroah-Hartman
0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2017-05-23 9:16 UTC (permalink / raw)
To: Rob Herring; +Cc: Johan Hovold, stable
On Mon, May 22, 2017 at 03:46:29PM -0500, Rob Herring wrote:
> On Mon, May 22, 2017 at 2:17 PM, <gregkh@linuxfoundation.org> wrote:
> >
> > The patch below does not apply to the 4.4-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
> >
> > thanks,
> >
> > greg k-h
> >
> > ------------------ original commit in Linus's tree ------------------
> >
> > From 49e67dd17649b60b4d54966e18ec9c80198227f0 Mon Sep 17 00:00:00 2001
> > From: Johan Hovold <johan@kernel.org>
> > Date: Wed, 17 May 2017 17:29:09 +0200
> > Subject: [PATCH] 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 <stable@vger.kernel.org> # 2.6.38
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> > Signed-off-by: Rob Herring <robh@kernel.org>
> >
> > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> > index a0972219ccfc..0373ae49d24d 100644
> > --- a/drivers/of/fdt.c
> > +++ b/drivers/of/fdt.c
> > @@ -507,6 +507,9 @@ void *__unflatten_device_tree(const void *blob,
>
> The context looks the same, it's just the line number is 416 in v4.4.
>
> >
> > /* Allocate memory for the expanded device tree */
> > mem = dt_alloc(size + 4, __alignof__(struct device_node));
> > + if (!mem)
> > + return NULL;
> > +
No, in 4.4 this function's return type is "void", not "void *" so the
build fails (well, has a warning, which means it isn't correct.)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-23 9:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-22 19:17 FAILED: patch "[PATCH] of: fdt: add missing allocation-failure check" failed to apply to 4.4-stable tree gregkh
2017-05-22 20:46 ` Rob Herring
2017-05-23 9:16 ` Greg Kroah-Hartman
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).