Re: [PATCH] usb: hub: Set proper message when usb_hub_create_port_device() fails
Chen-Yu Tsai <[email protected]>
| Newsgroups | org.kernel.vger.linux-usb,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAGXv+5HGZwAKpGpyV4=QHfg7yBQPx-syc1Gma2qad_tzW_RLog@mail.gmail.com> |
On Tue, Aug 11, 2026 at 12:31 AM Andy Shevchenko <[email protected]> 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