projects
/
project
/
bcm63xx
/
u-boot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ef53b8c
)
cmd: usb: check if_type before using this device
author
Peng Fan
<
[email protected]
>
Fri, 17 Jun 2016 06:18:11 +0000
(14:18 +0800)
committer
Marek Vasut
<
[email protected]
>
Fri, 17 Jun 2016 22:48:31 +0000
(
00:48
+0200)
For legacy usb storage driver, USB_MAX_STOR_DEV is defined as 7.
If we only have one usb disk on board, `usb dev 0` is ok.
But if `usb dev 1`, still ok, then `usb read xxx` will trigger
system fault and reboot.
So check if_type before using this device.
Signed-off-by: Peng Fan <
[email protected]
>
Cc: Simon Glass <
[email protected]
>
Cc: Hans de Goede <
[email protected]
>
Cc: Bin Meng <
[email protected]
>
Cc: Marek Vasut <
[email protected]
>
Cc: Stefan Roese <
[email protected]
>
Cc: Marcel Ziswiler <
[email protected]
>
Cc: Peng Fan <
[email protected]
>
Cc: Stephen Warren <
[email protected]
>
cmd/usb.c
patch
|
blob
|
history
diff --git
a/cmd/usb.c
b/cmd/usb.c
index b83d3233b789fffb49599ce2c9cf63abcc21112e..58d9db29d73ab151e85c37915bedabea59f10fba 100644
(file)
--- a/
cmd/usb.c
+++ b/
cmd/usb.c
@@
-800,7
+800,8
@@
static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int dev = (int)simple_strtoul(argv[2], NULL, 10);
printf("\nUSB device %d: ", dev);
stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, dev);
- if (stor_dev == NULL) {
+ if ((stor_dev == NULL) ||
+ (stor_dev->if_type == IF_TYPE_UNKNOWN)) {
printf("unknown device\n");
return 1;
}