Re: [PATCHv3 5/5] usb: gadget: udc-core: independent registration of gadgets and gadget drivers

From: Alan Stern
Date: Tue Mar 10 2015 - 21:31:44 EST


On Wed, 11 Mar 2015, Ruslan Bilovol wrote:

> Hi Alan,

Hello.

> > If you add the list_init and list_del_init above, this loop won't be
> > needed. You can just call list_del.
>
> I disagree with this. This function is externally visible and we can't
> guarantee that some buggy code will not call it with uninitialized
> 'pending' list_head. For example, if it never called usb_gadget_probe_driver()
> but calls usb_gadget_unregister_driver().
> As per my opinion it's better to check it and return -ENODEV rather than
> fail on deleting of uninitialized list_head. In this case adding the list_init
> and list_del_init above is not needed.

No, that is not the approach used in the rest of the kernel. We _want_
to know about bugs, so we can fix them. If you silently return -ENODEV
then nobody will realize anything is wrong, but a big fat WARN or OOPS
caused by an uninitialized list_head will draw people's attention very
quickly.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/