[U-Boot] [PATCH] fdt: Check if the FDT address is configured

In case the "fdt addr" command wasn't ran yet and any other "fdt" subcommand was issued, the system crashed due to NULL pointer being used.
This is caused by "fdt addr" command setting up a pointer to the FDT memory location. Prior issuing "fdt addr", the pointer is NULL so calling any other subcommands crashed the u-boot.
Signed-off-by: Marek Vasut marex@denx.de Cc: Simon Glass sjg@chromium.org --- common/cmd_fdt.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
Note: Damn, I'm falling asleep already :-( I hope the text above at least makes sense though.
diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 9a5c53e..e2225c4 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -114,10 +114,21 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } }
+ return CMD_RET_SUCCESS; + } + + if (!working_fdt) { + puts( + "No FDT memory address configured. Please configure\n" + "the FDT address via "fdt addr <address>" command.\n" + "Aborting!\n"); + return CMD_RET_FAILURE; + } + /* * Move the working_fdt */ - } else if (strncmp(argv[1], "mo", 2) == 0) { + if (strncmp(argv[1], "mo", 2) == 0) { struct fdt_header *newaddr; int len; int err;

Hi Marek,
I'll queue this up this weekend.
The merge window for v2012.10 closed September 18. Unless there is an overriding urgency, the patch will go into the following release.
On 09/05/2012 02:34 AM, Marek Vasut wrote:
In case the "fdt addr" command wasn't ran yet and any other "fdt" subcommand was issued, the system crashed due to NULL pointer being used.
This is caused by "fdt addr" command setting up a pointer to the FDT memory location. Prior issuing "fdt addr", the pointer is NULL so calling any other subcommands crashed the u-boot.
Signed-off-by: Marek Vasut marex@denx.de Cc: Simon Glass sjg@chromium.org
common/cmd_fdt.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
Note: Damn, I'm falling asleep already :-( I hope the text above at least makes sense though.
diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 9a5c53e..e2225c4 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -114,10 +114,21 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } }
return CMD_RET_SUCCESS;
- }
- if (!working_fdt) {
puts(
"No FDT memory address configured. Please configure\n"
"the FDT address via \"fdt addr <address>\" command.\n"
"Aborting!\n");
return CMD_RET_FAILURE;
- }
- /*
*/
- Move the working_fdt
- } else if (strncmp(argv[1], "mo", 2) == 0) {
- if (strncmp(argv[1], "mo", 2) == 0) { struct fdt_header *newaddr; int len; int err;
Thanks, gvb

Dear Jerry Van Baren,
Hi Marek,
I'll queue this up this weekend.
The merge window for v2012.10 closed September 18. Unless there is an overriding urgency, the patch will go into the following release.
It's a fix, I'd say queue it for current release. Only fixes go into current release after MW closed.
Thanks Jerry!
On 09/05/2012 02:34 AM, Marek Vasut wrote:
In case the "fdt addr" command wasn't ran yet and any other "fdt" subcommand was issued, the system crashed due to NULL pointer being used.
This is caused by "fdt addr" command setting up a pointer to the FDT memory location. Prior issuing "fdt addr", the pointer is NULL so calling any other subcommands crashed the u-boot.
Signed-off-by: Marek Vasut marex@denx.de Cc: Simon Glass sjg@chromium.org
common/cmd_fdt.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
Note: Damn, I'm falling asleep already :-( I hope the text above at
least makes sense though.
diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 9a5c53e..e2225c4 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -114,10 +114,21 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
}
}
return CMD_RET_SUCCESS;
}
if (!working_fdt) {
puts(
"No FDT memory address configured. Please configure\n"
"the FDT address via \"fdt addr <address>\" command.\n"
"Aborting!\n");
return CMD_RET_FAILURE;
}
/*
- Move the working_fdt
*/
- } else if (strncmp(argv[1], "mo", 2) == 0) {
if (strncmp(argv[1], "mo", 2) == 0) {
struct fdt_header *newaddr; int len; int err;
Thanks, gvb
Best regards, Marek Vasut

On Thu, Sep 13, 2012 at 10:30:29AM +0200, Marek Vasut wrote:
Dear Jerry Van Baren,
Hi Marek,
I'll queue this up this weekend.
The merge window for v2012.10 closed September 18. Unless there is an overriding urgency, the patch will go into the following release.
It's a fix, I'd say queue it for current release. Only fixes go into current release after MW closed.
I second what Marek says, this is a bugfix, so lets get it into the release. Thanks!

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 09/13/2012 01:37 PM, Tom Rini wrote:
On Thu, Sep 13, 2012 at 10:30:29AM +0200, Marek Vasut wrote:
Dear Jerry Van Baren,
Hi Marek,
I'll queue this up this weekend.
The merge window for v2012.10 closed September 18. Unless there is an overriding urgency, the patch will go into the following release.
It's a fix, I'd say queue it for current release. Only fixes go into current release after MW closed.
I second what Marek says, this is a bugfix, so lets get it into the release. Thanks!
OK, will do.
Thanks, gvb

On 09/05/2012 02:34 AM, Marek Vasut wrote:
In case the "fdt addr" command wasn't ran yet and any other "fdt" subcommand was issued, the system crashed due to NULL pointer being used.
This is caused by "fdt addr" command setting up a pointer to the FDT memory location. Prior issuing "fdt addr", the pointer is NULL so calling any other subcommands crashed the u-boot.
Signed-off-by: Marek Vasut marex@denx.de Cc: Simon Glass sjg@chromium.org
Applied and sent a pull request to Tom Rini.
Thanks, gvb
participants (3)
-
Jerry Van Baren
-
Marek Vasut
-
Tom Rini