]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
cmd_nand: Update (nand_info_t*)nand after arg_off(_size) call
authorRostislav Lisovy <lisovy@gmail.com>
Tue, 16 Sep 2014 12:38:52 +0000 (14:38 +0200)
committerTom Rini <trini@ti.com>
Wed, 24 Sep 2014 22:30:29 +0000 (18:30 -0400)
The arg_off() and arg_off_size() update the 'current NAND
device' variable (dev). This is then used when assigning the
(nand_info_t*)nand value. Place the assignment after the
arg_off(_size) calls to prevent using incorrect (nand_info_t*)
nand value.

Signed-off-by: Rostislav Lisovy <lisovy@merica.cz>
common/cmd_nand.c

index f9ced9d74cb0a5ff207c25d470eb6a45655688b2..7f962dcb25a080f892fde9d6b79934d9f428f6fd 100644 (file)
@@ -647,8 +647,6 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                read = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */
                printf("\nNAND %s: ", read ? "read" : "write");
 
-               nand = &nand_info[dev];
-
                s = strchr(cmd, '.');
 
                if (s && !strcmp(s, ".raw")) {
@@ -657,6 +655,8 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        if (arg_off(argv[3], &dev, &off, &size, &maxsize))
                                return 1;
 
+                       nand = &nand_info[dev];
+
                        if (argc > 4 && !str2long(argv[4], &pagecount)) {
                                printf("'%s' is not a number\n", argv[4]);
                                return 1;
@@ -679,6 +679,8 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        rwsize = size;
                }
 
+               nand = &nand_info[dev];
+
                if (!s || !strcmp(s, ".jffs2") ||
                    !strcmp(s, ".e") || !strcmp(s, ".i")) {
                        if (read)