catch wrong load address passed to fatload / ext2load
authorPavel Machek <pavel@denx.de>
Wed, 9 Jul 2014 20:42:57 +0000 (22:42 +0200)
committerTom Rini <trini@ti.com>
Tue, 22 Jul 2014 11:44:25 +0000 (07:44 -0400)
If filename is passed instead of address to ext2load or fatload,
u-boot silently accepts that, and uses 0 for load address and default
filename from environment. That is confusing, display help instead.

Signed-off-by: Pavel Machek <pavel@denx.de>
fs/fs.c

diff --git a/fs/fs.c b/fs/fs.c
index 79d432d58fe094c8eb09e04204114b8bd0d7f172..ea15c5f447bd3fb30ea4a5604a471b0b9a852110 100644 (file)
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -276,6 +276,7 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
        unsigned long pos;
        int len_read;
        unsigned long time;
+       char *ep;
 
        if (argc < 2)
                return CMD_RET_USAGE;
@@ -286,7 +287,9 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
                return 1;
 
        if (argc >= 4) {
-               addr = simple_strtoul(argv[3], NULL, 16);
+               addr = simple_strtoul(argv[3], &ep, 16);
+               if (ep == argv[3] || *ep != '\0')
+                       return CMD_RET_USAGE;
        } else {
                addr_str = getenv("loadaddr");
                if (addr_str != NULL)