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-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to