Re: [PATCH] of/fdt: avoid undefined behaviour in populate_properties()

From: Rob Herring
Date: Mon Jul 16 2018 - 10:36:49 EST


On Fri, Jul 6, 2018 at 10:51 AM Frank Rowand <frowand.list@xxxxxxxxx> wrote:
>
> On 07/06/18 04:37, Mark Rutland wrote:
> > We unflatten a device tree in two passes: the first calculating the size
> > of the unflattened tree, and the second performing the actual
> > unflattening into a suitably-sized buffer.

[...]

> > @@ -187,7 +187,9 @@ static void populate_properties(const void *blob,
> > int cur;
> > bool has_name = false;
> >
> > - pprev = &np->properties;
> > + if (!dryrun)
> > + pprev = &np->properties;
> > +
> > for (cur = fdt_first_property_offset(blob, offset);
> > cur >= 0;
> > cur = fdt_next_property_offset(blob, cur)) {
> >
>
> Please add a one line comment explaining why "if (!dryrun)" so that no one
> decides to remove the test in the future as not needed. Otherwise,

Please re-spin ASAP with the comment if you'd like this in 4.18.

Rob