aboutsummaryrefslogtreecommitdiff
path: root/cmd/fastboot.c
diff options
context:
space:
mode:
authorTom Rini2018-08-24 16:11:01 -0400
committerTom Rini2018-08-24 16:11:01 -0400
commit15fd1b7903a3090a03cfe453f661822a613a91ee (patch)
tree65ab83a17440b38d1c5b61f447e309291eb2ff28 /cmd/fastboot.c
parent8b7f04f14a1b790ff8dec0afc28a9e8477a6eb88 (diff)
parent49c752c93a785b9bad9d3fbbd52a76bec003eac5 (diff)
Merge branch 'master' of git://git.denx.de/u-boot-usb
Diffstat (limited to 'cmd/fastboot.c')
-rw-r--r--cmd/fastboot.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index e6ae0570d5b..ae3a5f627f1 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -38,13 +38,18 @@ static int do_fastboot_usb(int argc, char *const argv[],
#if CONFIG_IS_ENABLED(USB_FUNCTION_FASTBOOT)
int controller_index;
char *usb_controller;
+ char *endp;
int ret;
if (argc < 2)
return CMD_RET_USAGE;
usb_controller = argv[1];
- controller_index = simple_strtoul(usb_controller, NULL, 0);
+ controller_index = simple_strtoul(usb_controller, &endp, 0);
+ if (*endp != '\0') {
+ pr_err("Error: Wrong USB controller index format\n");
+ return CMD_RET_FAILURE;
+ }
ret = board_usb_init(controller_index, USB_INIT_DEVICE);
if (ret) {
@@ -120,6 +125,12 @@ NXTARG:
;
}
+ /* Handle case when USB controller param is just '-' */
+ if (argc == 1) {
+ pr_err("Error: Incorrect USB controller index\n");
+ return CMD_RET_USAGE;
+ }
+
fastboot_init((void *)buf_addr, buf_size);
if (!strcmp(argv[1], "udp"))