Messages in this thread |  | | Date | Tue, 10 Mar 2015 21:31:39 -0400 (EDT) | From | Alan Stern <> | Subject | Re: [PATCHv3 5/5] usb: gadget: udc-core: independent registration of gadgets and gadget drivers |
| |
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
|  |