summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-11-27 09:57:25 -0800
committerZachary T Welch <zw@superlucidity.net>2009-11-27 11:11:26 -0800
commitf31dfffdef16e640fa0bb881db1ac65ffcd42bf0 (patch)
tree5520632d1bfb14ffe95ef879c9c8b4dad0e82df7 /src
parent46ed068bacec3c40aa543e78e99b51e30aacf15b (diff)
downloadopenocd_libswd-f31dfffdef16e640fa0bb881db1ac65ffcd42bf0.tar.gz
openocd_libswd-f31dfffdef16e640fa0bb881db1ac65ffcd42bf0.tar.bz2
openocd_libswd-f31dfffdef16e640fa0bb881db1ac65ffcd42bf0.tar.xz
openocd_libswd-f31dfffdef16e640fa0bb881db1ac65ffcd42bf0.zip
fix 'nand info' command
Move device argument parsing after check for number of arguments; otherwise, calling this command without any arguments would access argv[0] before checking whether it even existed.
Diffstat (limited to 'src')
-rw-r--r--src/flash/nand.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/flash/nand.c b/src/flash/nand.c
index 1e28ba26..895abe31 100644
--- a/src/flash/nand.c
+++ b/src/flash/nand.c
@@ -1121,11 +1121,6 @@ COMMAND_HANDLER(handle_nand_info_command)
int first = -1;
int last = -1;
- struct nand_device *p;
- int retval = CALL_COMMAND_HANDLER(nand_command_get_device, 0, &p);
- if (ERROR_OK != retval)
- return retval;
-
switch (CMD_ARGC) {
default:
return ERROR_COMMAND_SYNTAX_ERROR;
@@ -1144,6 +1139,11 @@ COMMAND_HANDLER(handle_nand_info_command)
break;
}
+ struct nand_device *p;
+ int retval = CALL_COMMAND_HANDLER(nand_command_get_device, 0, &p);
+ if (ERROR_OK != retval)
+ return retval;
+
if (NULL == p->device)
{
command_print(CMD_CTX, "#%s: not probed", CMD_ARGV[0]);