lkml.org 
[lkml]   [2015]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCHv3 5/5] usb: gadget: udc-core: independent registration of gadgets and gadget drivers
Hi,

On Wed, Mar 11, 2015 at 02:21:38AM +0200, Ruslan Bilovol wrote:
> >> @@ -469,6 +488,16 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
> >> break;
> >> }
> >>
> >> + if (ret) {
> >> + struct usb_gadget_driver *tmp;
> >> +
> >> + list_for_each_entry(tmp, &gadget_driver_pending_list, pending)
> >> + if (tmp == driver) {
> >> + list_del(&driver->pending);
> >> + ret = 0;
> >> + break;
> >> + }
> >> + }
> >
> > 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().

those cases deserve to suffer a really painfull and horrible death by
means of a kernel oops ;-) Sure, defensive programming and all, but at
some point we need to consider certain cases ridiculous and just not do
anything about them, so people know that they need more coffee and
attention while writing code.

--
balbi
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2015-03-11 03:01    [W:0.063 / U:3.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site