public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@freescale.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Ruslan Bilovol <ruslan.bilovol@gmail.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Subject: Re: [PATCH v7 4/4] usb: gadget: udc-core: independent registration of gadgets and gadget drivers
Date: Tue, 24 Nov 2015 10:24:50 +0800	[thread overview]
Message-ID: <20151124022449.GA25698@shlinux2> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1511231029080.1831-100000@iolanthe.rowland.org>

On Mon, Nov 23, 2015 at 10:32:53AM -0500, Alan Stern wrote:
> On Mon, 23 Nov 2015, Marek Szyprowski wrote:
> 
> > From: Ruslan Bilovol <ruslan.bilovol@gmail.com>
> > 
> > Change behavior during registration of gadgets and
> > gadget drivers in udc-core. Instead of previous
> > approach when for successful probe of usb gadget driver
> > at least one usb gadget should be already registered
> > use another one where gadget drivers and gadgets
> > can be registered in udc-core independently.
> > 
> > Independent registration of gadgets and gadget drivers
> > is useful for built-in into kernel gadget and gadget
> > driver case - because it's possible that gadget is
> > really probed only on late_init stage (due to deferred
> > probe) whereas gadget driver's probe is silently failed
> > on module_init stage due to no any UDC added.
> > 
> > Also it is useful for modules case - now there is no
> > difference what module to insert first: gadget module
> > or gadget driver one.
> > 
> > Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
> > [simplified code as requested by Alan Stern and Felipe Balbi,
> >  fixed checkpatch issues]
> > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > Tested-by: Peter Chen <peter.chen@freescale.com>
> 
> I missed this the last time through...
> 
> > @@ -403,6 +408,18 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget,
> >  	usb_gadget_set_state(gadget, USB_STATE_NOTATTACHED);
> >  	udc->vbus = true;
> >  
> > +	/* pick up one of pending gadget drivers */
> > +	list_for_each_entry(driver, &gadget_driver_pending_list, pending) {
> > +		if (!driver->udc_name || strcmp(driver->udc_name,
> > +						dev_name(&udc->dev)) == 0) {
> > +			ret = udc_bind_to_driver(udc, driver);
> > +			if (ret)
> > +				goto err4;
> > +			list_del(&driver->pending);
> 
> This has to be list_del_init().  And somewhere in
> usb_gadget_probe_driver() you need to do
> INIT_LIST_HEAD(&driver->pending).
> 
> > @@ -577,6 +596,10 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
> >  			break;
> >  		}
> >  
> > +	if (ret) {
> > +		list_del(&driver->pending);
> 
> Otherwise this will cause a crash or corrupt some random area of 
> memory.
> 

Alan, would you please explain more what use case will cause memory
corruption for above code?

-- 

Best Regards,
Peter Chen

  reply	other threads:[~2015-11-24  2:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-23  8:56 [PATCH v7 0/4] usb/gadget: independent registration of gadgets and gadget drivers Marek Szyprowski
2015-11-23  8:56 ` [PATCH v7 1/4] usb: gadget: bind UDC by name passed via usb_gadget_driver structure Marek Szyprowski
2015-11-23  8:56 ` [PATCH v7 2/4] usb: gadget: configfs: pass UDC name via usb_gadget_driver struct Marek Szyprowski
2015-11-23  8:56 ` [PATCH v7 3/4] usb: gadget: udc-core: remove unused usb_udc_attach_driver() Marek Szyprowski
2015-11-23  8:56 ` [PATCH v7 4/4] usb: gadget: udc-core: independent registration of gadgets and gadget drivers Marek Szyprowski
2015-11-23 15:32   ` Alan Stern
2015-11-24  2:24     ` Peter Chen [this message]
2015-11-24 15:53       ` Alan Stern
2015-11-24 12:38     ` Marek Szyprowski
2015-11-26 13:12 ` [PATCH v7 0/4] usb/gadget: " Ruslan Bilovol
2015-12-10 17:01 ` Felipe Balbi
2015-12-10 17:09   ` Felipe Balbi
2015-12-10 17:13     ` Felipe Balbi
2015-12-11  9:37       ` Marek Szyprowski
2015-12-14  8:08       ` Peter Chen

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=20151124022449.GA25698@shlinux2 \
    --to=peter.chen@freescale.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.szyprowski@samsung.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