2015-04-14 04:36:40

by Ricky Liang

[permalink] [raw]
Subject: [PATCH] of/fdt: fix allocation size for device node path

The allocation size of device node path is off by one which drops the
'\0' terminator.

Signed-off-by: Ricky Liang <[email protected]>
---
drivers/of/fdt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 3a896c9..98a9e6e 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -172,7 +172,7 @@ static void * unflatten_dt_node(void *blob,
if (!pathp)
return mem;

- allocl = l++;
+ allocl = ++l;

/* version 0x10 has a more compact unit name here instead of the full
* path. we accumulate the full path size using "fpsize", we'll rebuild
--
2.1.2


2015-04-15 12:15:27

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH] of/fdt: fix allocation size for device node path

On Tue, 14 Apr 2015 12:36:05 +0800
, Ricky Liang <[email protected]>
wrote:
> The allocation size of device node path is off by one which drops the
> '\0' terminator.
>
> Signed-off-by: Ricky Liang <[email protected]>

This looks like something that should be backported to stable. Do you agree?

g.

> ---
> drivers/of/fdt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 3a896c9..98a9e6e 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -172,7 +172,7 @@ static void * unflatten_dt_node(void *blob,
> if (!pathp)
> return mem;
>
> - allocl = l++;
> + allocl = ++l;
>
> /* version 0x10 has a more compact unit name here instead of the full
> * path. we accumulate the full path size using "fpsize", we'll rebuild
> --
> 2.1.2
>

2015-04-15 13:00:31

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH] of/fdt: fix allocation size for device node path

On Wed, Apr 15, 2015 at 7:15 AM, Grant Likely <[email protected]> wrote:
> On Tue, 14 Apr 2015 12:36:05 +0800
> , Ricky Liang <[email protected]>
> wrote:
>> The allocation size of device node path is off by one which drops the
>> '\0' terminator.
>>
>> Signed-off-by: Ricky Liang <[email protected]>
>
> This looks like something that should be backported to stable. Do you agree?

I've applied, but didn't tag it. I'll send it for stable once it is in
Linus' tree.

BTW, it only affects old dtb versions less than 0x10 because allocl is
overwritten in the 'if' statement just below here.

Rob

>
> g.
>
>> ---
>> drivers/of/fdt.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> index 3a896c9..98a9e6e 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -172,7 +172,7 @@ static void * unflatten_dt_node(void *blob,
>> if (!pathp)
>> return mem;
>>
>> - allocl = l++;
>> + allocl = ++l;
>>
>> /* version 0x10 has a more compact unit name here instead of the full
>> * path. we accumulate the full path size using "fpsize", we'll rebuild
>> --
>> 2.1.2
>>
>