diff mbox

[U-Boot] cmd_fdt: save fdtaddr in hex format

Message ID 1436545124-31814-1-git-send-email-sudeep.holla@arm.com
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Sudeep Holla July 10, 2015, 4:18 p.m. UTC
Commit 90fbee3e4051 ("cmd_fdt: Actually fix fdt command in sandbox")
changed the format(from hex address to unsigned long) in which "fdtaddr"
is saved . However do_fdt continues reads the "fdtaddr" assuming it to
be in hex format. This may lead to fdt being either loaded or attempted
to load at erroneous address generating fault if the address is out of
memory.

This patch changes back the format to hex while saving the "fdtaddr"
as it was done before.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Hua Yanghao <huayanghao@gmail.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_fdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Reposting this time with my signoff as it turns out I can legally do so.

Comments

Simon Glass July 10, 2015, 11:08 p.m. UTC | #1
On 10 July 2015 at 10:18, Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> Commit 90fbee3e4051 ("cmd_fdt: Actually fix fdt command in sandbox")
> changed the format(from hex address to unsigned long) in which "fdtaddr"
> is saved . However do_fdt continues reads the "fdtaddr" assuming it to
> be in hex format. This may lead to fdt being either loaded or attempted
> to load at erroneous address generating fault if the address is out of
> memory.
>
> This patch changes back the format to hex while saving the "fdtaddr"
> as it was done before.
>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Hua Yanghao <huayanghao@gmail.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>  common/cmd_fdt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Reposting this time with my signoff as it turns out I can legally do so.
>

Great!

- Simon
Linus Walleij July 16, 2015, 1:26 p.m. UTC | #2
On Fri, Jul 10, 2015 at 6:18 PM, Sudeep Holla <sudeep.holla@arm.com> wrote:

> Commit 90fbee3e4051 ("cmd_fdt: Actually fix fdt command in sandbox")
> changed the format(from hex address to unsigned long) in which "fdtaddr"
> is saved . However do_fdt continues reads the "fdtaddr" assuming it to
> be in hex format. This may lead to fdt being either loaded or attempted
> to load at erroneous address generating fault if the address is out of
> memory.
>
> This patch changes back the format to hex while saving the "fdtaddr"
> as it was done before.
>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Hua Yanghao <huayanghao@gmail.com>
> Cc: Heiko Schocher <hs@denx.de>

Looks like the right fix:
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Simon Glass July 16, 2015, 4:34 p.m. UTC | #3
On 16 July 2015 at 07:26, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Fri, Jul 10, 2015 at 6:18 PM, Sudeep Holla <sudeep.holla@arm.com> wrote:
>
>> Commit 90fbee3e4051 ("cmd_fdt: Actually fix fdt command in sandbox")
>> changed the format(from hex address to unsigned long) in which "fdtaddr"
>> is saved . However do_fdt continues reads the "fdtaddr" assuming it to
>> be in hex format. This may lead to fdt being either loaded or attempted
>> to load at erroneous address generating fault if the address is out of
>> memory.
>>
>> This patch changes back the format to hex while saving the "fdtaddr"
>> as it was done before.
>>
>> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
>> Cc: Linus Walleij <linus.walleij@linaro.org>
>> Cc: Tom Rini <trini@konsulko.com>
>> Cc: Simon Glass <sjg@chromium.org>
>> Cc: Hua Yanghao <huayanghao@gmail.com>
>> Cc: Heiko Schocher <hs@denx.de>
>
> Looks like the right fix:
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>
> Yours,
> Linus Walleij

Acked-by: Simon Glass <sjg@chromium.org>
Simon Glass July 20, 2015, 1:25 p.m. UTC | #4
On 16 July 2015 at 10:34, Simon Glass <sjg@chromium.org> wrote:
> On 16 July 2015 at 07:26, Linus Walleij <linus.walleij@linaro.org> wrote:
>> On Fri, Jul 10, 2015 at 6:18 PM, Sudeep Holla <sudeep.holla@arm.com> wrote:
>>
>>> Commit 90fbee3e4051 ("cmd_fdt: Actually fix fdt command in sandbox")
>>> changed the format(from hex address to unsigned long) in which "fdtaddr"
>>> is saved . However do_fdt continues reads the "fdtaddr" assuming it to
>>> be in hex format. This may lead to fdt being either loaded or attempted
>>> to load at erroneous address generating fault if the address is out of
>>> memory.
>>>
>>> This patch changes back the format to hex while saving the "fdtaddr"
>>> as it was done before.
>>>
>>> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
>>> Cc: Linus Walleij <linus.walleij@linaro.org>
>>> Cc: Tom Rini <trini@konsulko.com>
>>> Cc: Simon Glass <sjg@chromium.org>
>>> Cc: Hua Yanghao <huayanghao@gmail.com>
>>> Cc: Heiko Schocher <hs@denx.de>
>>
>> Looks like the right fix:
>> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>>
>> Yours,
>> Linus Walleij
>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-fdt, thanks!
diff mbox

Patch

diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index 682b6553958f..4c18962d8532 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -45,7 +45,7 @@  void set_working_fdt_addr(ulong addr)
 
 	buf = map_sysmem(addr, 0);
 	working_fdt = buf;
-	setenv_ulong("fdtaddr", addr);
+	setenv_hex("fdtaddr", addr);
 }
 
 /*