* [U-Boot] [PATCH] cmd: usb: check if_type before using this device
@ 2016-06-17 6:18 Peng Fan
2016-06-17 22:48 ` Marek Vasut
2016-06-17 23:00 ` Simon Glass
0 siblings, 2 replies; 3+ messages in thread
From: Peng Fan @ 2016-06-17 6:18 UTC (permalink / raw)
To: u-boot
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 <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stephen Warren <swarren@nvidia.com>
---
cmd/usb.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/cmd/usb.c b/cmd/usb.c
index b83d323..58d9db2 100644
--- 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;
}
--
2.6.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* [U-Boot] [PATCH] cmd: usb: check if_type before using this device
2016-06-17 6:18 [U-Boot] [PATCH] cmd: usb: check if_type before using this device Peng Fan
@ 2016-06-17 22:48 ` Marek Vasut
2016-06-17 23:00 ` Simon Glass
1 sibling, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2016-06-17 22:48 UTC (permalink / raw)
To: u-boot
On 06/17/2016 08:18 AM, Peng Fan wrote:
> 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.
Applied, thanks
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Stefan Roese <sr@denx.de>
> Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Stephen Warren <swarren@nvidia.com>
> ---
> cmd/usb.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/cmd/usb.c b/cmd/usb.c
> index b83d323..58d9db2 100644
> --- 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;
> }
>
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 3+ messages in thread* [U-Boot] [PATCH] cmd: usb: check if_type before using this device
2016-06-17 6:18 [U-Boot] [PATCH] cmd: usb: check if_type before using this device Peng Fan
2016-06-17 22:48 ` Marek Vasut
@ 2016-06-17 23:00 ` Simon Glass
1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2016-06-17 23:00 UTC (permalink / raw)
To: u-boot
On 17 June 2016 at 00:18, Peng Fan <van.freenix@gmail.com> wrote:
> 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 <peng.fan@nxp.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Stefan Roese <sr@denx.de>
> Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Stephen Warren <swarren@nvidia.com>
> ---
> cmd/usb.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-17 23:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-17 6:18 [U-Boot] [PATCH] cmd: usb: check if_type before using this device Peng Fan
2016-06-17 22:48 ` Marek Vasut
2016-06-17 23:00 ` Simon Glass
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox