Re: [PATCH] usb: hub: Set proper message when usb_hub_create_port_device() fails

From: Chen-Yu Tsai

Date: Mon Aug 10 2026 - 23:51:30 EST


On Tue, Aug 11, 2026 at 12:31 AM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Tue, Jul 28, 2026 at 06:00:04PM +0800, Chen-Yu Tsai wrote:
> > 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.
>
> The 'message' is local to the function, why devm?
> Shouldn't __free() be sufficient?

I hadn't thought of that.

The scope shouldn't be a problem, since it's declared and used at the top
level. But we'd need a kfree_const() variant of __free(kfree). All the
other error messages are just plain C string constants.


ChenYu