Skip to contentSkip to conversation

cmd_nand: Update (nand_info_t*)nand after arg_off(_size) call

PATCH Superseded Rostislav Lisovy 2 participants 2 messages Sep 16, 2014 – Sep 25, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd_nand: Update (nand_info_t*)nand after arg_off(_size) call

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.

---
 common/cmd_nand.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
common/cmd_nand.c +4 -2
index f9ced9d..7f962dc 100644
@@ -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)
Signature · 1 line
1.9.1
#1 lore raw
Quoted 7 lines · Rostislav Lisovy

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.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140925/5e79e86a/attachment.pgp>