[PATCH] cmd: usb: Prevent reset in usb tree/info command

Marek Vasut marex at denx.de
Thu Jun 8 00:05:18 CEST 2023


On 6/5/23 17:20, Xavier Drudis Ferran wrote:
> Add a check to avoid dommed (by null pointer dereference) recursive
> call, not only for UCLASS_BLK.
> 
> When booting my Rock Pi 4B+ with a USB mass storage stick plugged
> into one of the USB 2 ports (EHCI), when it is plugged before power
> on, when issuing a
> 
> usb tree
> 
> or
> 
> usb info

I cannot reproduce the problem. Do you perform any other interaction 
with the USB stack, like e.g. 'usb start' or 'usb reset' before issuing 
the aforementioned commands ?

What kind of USB stick is used here, please share model, VID, PID.

> command I get a "Synchronous Error" and a reset just after printing the
> mass storage device in the usb tree or usb info. It might depend on the
> contents of the USB stick too, I'm not sure.
> 
> It seems like I have two devices as children of the mass storage
> device.  When there's only a UCLASS_BLK it works fine, but when there's
> a UCLASS_BLK and a UCLASS_BOOTDEV, it recurses with a null udev as
> first parameter and fails.
> 
> Likewise for usb_show_info().
> 
> Not sure if this should be a patch, an RFC or a bug report.  There may
> be a better way to solve this, I haven't researched commit
> 201417d700a2ab09 ("bootstd: Add the bootdev uclass") and bootdev flow
> properly, or thought about cases where udev is not null but the
> recursive call might need preventing too. Feel free to think it over
> before merging (or after).

It is unclear what the real issue is, so until that is sorted out, no 
merging will occur, sorry.

> But this at least fixes a reset at an
> innocent looking usb tree or usb info command. Maybe we can improve it
> later?

NAK, please let's not add ad-hoc poorly understood changes into core code.


More information about the U-Boot mailing list