Re: [PATCH] net: usb: Make init_satus() return -ENOMEM if alloc failed

From: qiang . zhang
Date: Wed Jul 16 2025 - 20:05:22 EST


>
> On Wed, Jul 16, 2025 at 08:15:23AM +0800, Zqiang wrote:
>
> >
> > This commit make init_status() return -ENOMEM, if invoke
> >
> > kmalloc() return failed.
> >
> >
> >
> > Signed-off-by: Zqiang <qiang.zhang@xxxxxxxxx>
> >
>
> Hi,
>
> It seems to me that the code has been structured so that
>
> this case is not treated as an error, and rather initialisation
>
> that depends on it is skipped.

Yes, your point is also correct, but in theory,
if usb_alloc_urb() allocation fails, we should
also return a value of 0, should we keep the
two behaviors consistent?

>
> Are you sure this change is correct?


For drivers that have a driver_info->status method, it is generally
needto allocate an interrupt urb and fill it to obtain some
status information, but if kmalloc() faild and return 0 in init_status(),
and some dirvers directly call usbnet_status_start(),
the WARN_ONCE(dev->interrupt == NULL) will be trigger.

Thanks
Zqiang


>