lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250220095218.970-1-vulab@iscas.ac.cn>
Date: Thu, 20 Feb 2025 17:52:18 +0800
From: Wentao Liang <vulab@...as.ac.cn>
To: gregkh@...uxfoundation.org
Cc: stern@...land.harvard.edu,
	christophe.jaillet@...adoo.fr,
	mka@...omium.org,
	make_ruc2021@....com,
	javier.carrasco@...fvision.net,
	linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Wentao Liang <vulab@...as.ac.cn>,
	stable@...r.kernel.org
Subject: [PATCH] usb: core: Add error handling in usb_reset_device for autoresume failure

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@...r.kernel.org # 2.6.20+
Signed-off-by: Wentao Liang <vulab@...as.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);
+	ret = usb_autoresume_device(udev);
+	if (ret < 0)
+		goto error_autoresume;
 
 	if (config) {
 		for (i = 0; i < config->desc.bNumInterfaces; ++i) {
@@ -6341,6 +6343,7 @@ int usb_reset_device(struct usb_device *udev)
 	}
 
 	usb_autosuspend_device(udev);
+error_autoresume:
 	memalloc_noio_restore(noio_flag);
 	udev->reset_in_progress = 0;
 	return ret;
-- 
2.42.0.windows.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ