On Thu, Feb 20, 2025 at 05:52:18PM +0800, Wentao Liang wrote:
In usb_reset_device(), the function continues execution and calls usb_autosuspend_device() after usb_autosuspend_device fails.
To fix this, add error handling for usb_autoresume_device() and return the error code immediately. This ensures that usb_autosuspend_device() is not called when usb_autoresume_device() fails, maintaining device state consistency.
Fixes: 94fcda1f8ab5 ("usbcore: remove unused argument in autosuspend") Cc: stable@vger.kernel.org # 2.6.20+ Signed-off-by: Wentao Liang vulab@iscas.ac.cn
drivers/usb/core/hub.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 21ac9b464696..f2efdbdd1533 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -6292,7 +6292,9 @@ int usb_reset_device(struct usb_device *udev) noio_flag = memalloc_noio_save(); /* Prevent autosuspend during the reset */
- usb_autoresume_device(udev);
Have you ever seen this function fail?
- ret = usb_autoresume_device(udev);
- if (ret < 0)
if (ret) please.
Also, how was this tested? How was it found?
thanks,
greg k-h