mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] usb: core: handle port status errors in disable_show()
@ 2026-08-10 23:04 Karl Mehltretter
  2026-08-11 14:17 ` Alan Stern
  2026-09-12  8:55 ` Karl Mehltretter
  0 siblings, 2 replies; 3+ messages in thread
From: Karl Mehltretter @ 2026-08-10 23:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Karl Mehltretter, Alan Stern, Michael Grzeschik, linux-usb, linux-kernel

usb_hub_port_status() leaves its output arguments untouched when the
status request fails. disable_show() nevertheless uses portstatus, so a
sysfs read may report the wrong port state instead of an error.

Propagate the status request error.

Fixes: f061f43d7418c ("usb: hub: port: add sysfs entry to switch port power")
Assisted-by: Claude:claude-fable-5
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
---
Changes in v2:
- Simplify error handling (Alan Stern).

v1: https://lore.kernel.org/r/20260808131601.75096-1-kmehltretter@gmail.com/

 drivers/usb/core/port.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index b4452b665f59..6503668f303b 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -96,8 +96,9 @@ static ssize_t disable_show(struct device *dev,
 		goto out_hdev_lock;
 	}
 
-	usb_hub_port_status(hub, port1, &portstatus, &unused);
-	disabled = !usb_port_is_power_on(hub, portstatus);
+	rc = usb_hub_port_status(hub, port1, &portstatus, &unused);
+	if (rc >= 0)
+		disabled = !usb_port_is_power_on(hub, portstatus);
 
  out_hdev_lock:
 	usb_unlock_device(hdev);
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-12  8:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-10 23:04 [PATCH v2] usb: core: handle port status errors in disable_show() Karl Mehltretter
2026-08-11 14:17 ` Alan Stern
2026-09-12  8:55 ` Karl Mehltretter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®