RE: [PATCH][bugfix] usb/gadget: configfs: keep a function if it is not successfully added

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday, August 08, 2013 6:02 PM Sebastian Andrzej Siewior wrote:
> On 08/08/2013 09:43 AM, Andrzej Pietrasiewicz wrote:
> > diff --git a/drivers/usb/gadget/configfs.c
> > b/drivers/usb/gadget/configfs.c index c5d8f81..8cb5006 100644
> > --- a/drivers/usb/gadget/configfs.c
> > +++ b/drivers/usb/gadget/configfs.c
> > @@ -866,8 +866,10 @@ static int configfs_composite_bind(struct
> usb_gadget *gadget,
> >  		list_for_each_entry_safe(f, tmp, &cfg->func_list, list) {
> >  			list_del(&f->list);
> >  			ret = usb_add_function(c, f);
> > -			if (ret)
> > +			if (ret) {
> > +				list_add(&f->list, &cfg->func_list);
> >  				goto err_purge_funcs;
> > +			}
> 
> Since when is this broken? I remember it used to work and
> usb_add_function() cleaned up after itself in error case.

When usb_add_function() completes then either the function is
added and is in the list in struct usb_configuration, or is not
added and not in this list. So it does clean up after itself.

But how can usb_add_function() know that the function in question
should be returned to some list in struct config_usb_cfg?

In the error case I described in the commit message the situation
is like this: the function is not in either list. The next time
a bind is attempted ($ echo <udc-name> > UDC, e.g. after
the user has resolved some problems) the configfs_composite_bind()
is invoked again. And this time the function in question is not
in the list in struct config_usb_cfg and will never be bound.

Andrzej

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux