On Wed, 1 Mar 2017, Peter Chen wrote:

> On Tue, Feb 28, 2017 at 11:07:08AM -0500, Alan Stern wrote:
> > On Tue, 28 Feb 2017, Peter Chen wrote:
> > 
> > > When the user does device unbind and rebind test, the kernel will
> > > show below dump due to usb_gadget memory region is dirty after unbind.
> > > Clear usb_gadget region for every new probe.

> > > diff --git a/drivers/usb/gadget/udc/dummy_hcd.c 
> > > b/drivers/usb/gadget/udc/dummy_hcd.c
> > > index c60abe3..8cabc59 100644
> > > --- a/drivers/usb/gadget/udc/dummy_hcd.c
> > > +++ b/drivers/usb/gadget/udc/dummy_hcd.c
> > > @@ -1031,6 +1031,8 @@ static int dummy_udc_probe(struct platform_device 
> > > *pdev)
> > >   int             rc;
> > >  
> > >   dum = *((void **)dev_get_platdata(&pdev->dev));
> > > + /* Clear usb_gadget region for new registration to udc-core */
> > > + memzero_explicit(&dum->gadget, sizeof(struct usb_gadget));
> > >   dum->gadget.name = gadget_name;
> > >   dum->gadget.ops = &dummy_ops;
> > >   dum->gadget.max_speed = USB_SPEED_SUPER;
> > 
> > Wouldn't it be better to clear the entire structure, not just
> > dum->gadget?  Then you could also change
> > 
> >             dum[i] = kzalloc(sizeof(struct dummy), GFP_KERNEL);
> > 
> > to use kmalloc, since the structure will be initialized by the probe 
> > routine.
> > 
> 
> The memory region of dum is shared between dummy_hcd and dummy_udc.
> If clear entire dum, the entries for dummy_hcd will be cleared.

Ooh, yes, that's true.  Okay, you have my

Acked-by: Alan Stern <st...@rowland.harvard.edu>

for this patch.

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