public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@ti.com>
To: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	"Balbi, Felipe" <balbi@ti.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Krzysztof Opasiak <k.opasiak@samsung.com>,
	Peter Chen <peter.chen@freescale.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Subject: Re: [PATCHv3 5/5] usb: gadget: udc-core: independent registration of gadgets and gadget drivers
Date: Tue, 10 Mar 2015 20:53:11 -0500	[thread overview]
Message-ID: <20150311015311.GC21726@saruman.tx.rr.com> (raw)
In-Reply-To: <CAB=otbQHh+ZE0xTGRDZsM=5Pr=TCj3Qz8e54WpVJpqhA9VW2Tg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

      parent reply	other threads:[~2015-03-11  1:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-17 21:17 [PATCHv3 0/5] usb/gadget: independent registration of gadgets and gadget drivers Ruslan Bilovol
2015-02-17 21:17 ` [PATCHv3 1/5] usb: gadget: bind UDC by name passed via usb_gadget_driver structure Ruslan Bilovol
2015-02-18 12:05   ` Sergei Shtylyov
2015-03-11  0:24     ` Ruslan Bilovol
2015-02-17 21:17 ` [PATCHv3 2/5] usb: gadge: configfs: pass UDC name via usb_gadget_driver struct Ruslan Bilovol
2015-02-17 21:17 ` [PATCHv3 3/5] usb: gadget: udc-core: remove unused usb_udc_attach_driver() Ruslan Bilovol
2015-02-17 21:17 ` [PATCHv3 4/5] usb: gadget: legacy: don't use __init/__exit attributes for bind/unbind path Ruslan Bilovol
2015-02-17 21:17 ` [PATCHv3 5/5] usb: gadget: udc-core: independent registration of gadgets and gadget drivers Ruslan Bilovol
2015-02-17 21:51   ` Alan Stern
2015-03-11  0:21     ` Ruslan Bilovol
2015-03-11  1:31       ` Alan Stern
2015-03-11  1:53       ` Felipe Balbi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150311015311.GC21726@saruman.tx.rr.com \
    --to=balbi@ti.com \
    --cc=andrzej.p@samsung.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=k.opasiak@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.chen@freescale.com \
    --cc=ruslan.bilovol@gmail.com \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox