From: Karl Mehltretter <kmehltretter@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Karl Mehltretter <kmehltretter@gmail.com>,
Alan Stern <stern@rowland.harvard.edu>,
Michael Grzeschik <m.grzeschik@pengutronix.de>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] usb: core: handle port status errors in disable_show()
Date: Sat, 8 Aug 2026 15:16:01 +0200 [thread overview]
Message-ID: <20260808131601.75096-1-kmehltretter@gmail.com> (raw)
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>
---
drivers/usb/core/port.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index b4452b665f591..0022473e526d7 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -96,7 +96,9 @@ static ssize_t disable_show(struct device *dev,
goto out_hdev_lock;
}
- usb_hub_port_status(hub, port1, &portstatus, &unused);
+ rc = usb_hub_port_status(hub, port1, &portstatus, &unused);
+ if (rc < 0)
+ goto out_hdev_lock;
disabled = !usb_port_is_power_on(hub, portstatus);
out_hdev_lock:
--
2.53.0
next reply other threads:[~2026-08-08 13:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-08 13:16 Karl Mehltretter [this message]
2026-08-08 13:44 ` Alan Stern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260808131601.75096-1-kmehltretter@gmail.com \
--to=kmehltretter@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.grzeschik@pengutronix.de \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®