Re: [PATCH] usb/chipidea: fix oops on memory allocation failure

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

 



On Thu, Oct 17, 2013 at 10:43:17AM +0100, Russell King - ARM Linux wrote:
> On Thu, Oct 17, 2013 at 01:50:17PM +0800, Peter Chen wrote:
> > Below is my proposal fix for this problem: 
> > 
> > diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
> > index 42a0bd4..c1d05c4 100644
> > --- a/drivers/usb/chipidea/host.c
> > +++ b/drivers/usb/chipidea/host.c
> > @@ -270,16 +270,18 @@ static void host_stop(struct ci_hdrc *ci)
> >  {
> >  	struct usb_hcd *hcd = ci->hcd;
> >  
> > -	usb_remove_hcd(hcd);
> > -	usb_put_hcd(hcd);
> > -	if (ci->platdata->reg_vbus)
> > -		regulator_disable(ci->platdata->reg_vbus);
> > +	if (hcd) {
> > +		usb_remove_hcd(hcd);
> > +		usb_put_hcd(hcd);
> > +		if (ci->platdata->reg_vbus)
> > +			regulator_disable(ci->platdata->reg_vbus);
> > +	}
> >  }
> >  
> >  
> >  void ci_hdrc_host_destroy(struct ci_hdrc *ci)
> >  {
> > -	if (ci->role == CI_ROLE_HOST)
> > +	if (ci->role == CI_ROLE_HOST && ci->hcd)
> >  		host_stop(ci);
> 
> If you're not calling host_stop() unless ci->hcd is setup, then you
> don't need to check for that in host_stop() ?  Note that my oopsing
> path is through the above function.

Mine is just double check, this host_stop is called from ci_hdrc_host_destroy
For your oops, your fix is enough since regulator_enable has already been
called. But if the host_start fails at the beginning, eg usb_create_hcd
returns NULL, you need to consider regulator mismatch case.

-- 

Best Regards,
Peter Chen

--
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