All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: hub: Set proper message when usb_hub_create_port_device() fails
@ 2026-07-28 10:00 Chen-Yu Tsai
  2026-08-10 16:31 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Chen-Yu Tsai @ 2026-07-28 10:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Chen-Yu Tsai, Bartosz Golaszewski, Andy Shevchenko, linux-usb,
	linux-kernel

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


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

end of thread, other threads:[~2026-08-11  7:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28 10:00 [PATCH] usb: hub: Set proper message when usb_hub_create_port_device() fails Chen-Yu Tsai
2026-08-10 16:31 ` Andy Shevchenko
2026-08-11  3:51   ` Chen-Yu Tsai
2026-08-11  7:14     ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.