From: Chen-Yu Tsai <wenst@chromium.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Chen-Yu Tsai <wenst@chromium.org>,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] usb: hub: Set proper message when usb_hub_create_port_device() fails
Date: Tue, 28 Jul 2026 18:00:04 +0800 [thread overview]
Message-ID: <20260728100005.413868-1-wenst@chromium.org> (raw)
Right now when usb_hub_create_port_device() fails, it prints a separate
error message to say which port failed, but otherwise leaves 'message'
set to the default "out of memory", which is somewhat misleading.
Allocate some memory and put the currently separate error message in
it, and use it as the error message. If the allocation fails, use a
generic version of the error message. The allocation uses devres
helpers, and will be freed after the message is printed and the device
is cleaned up.
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---
drivers/usb/core/hub.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b09b43669658..fc4879d9c623 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1751,8 +1751,15 @@ static int hub_configure(struct usb_hub *hub,
for (i = 0; i < maxchild; i++) {
ret = usb_hub_create_port_device(hub, i + 1);
if (ret < 0) {
- dev_err(hub->intfdev,
- "couldn't create port%d device.\n", i + 1);
+ char *msg;
+
+ msg = devm_kasprintf(hub->intfdev, GFP_KERNEL,
+ "couldn't create port%d device",
+ i + 1);
+ if (msg)
+ message = msg;
+ else
+ message = "couldn't create port device";
break;
}
}
--
2.55.0.229.g6434b31f56-goog
reply other threads:[~2026-07-28 10:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260728100005.413868-1-wenst@chromium.org \
--to=wenst@chromium.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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