Skip to content

Commit

Permalink
usb: gadget: function: phonet: balance usb_ep_disable calls
Browse files Browse the repository at this point in the history
f_phonet's ->set_alt() method will call usb_ep_disable()
potentially on an endpoint which is already disabled. That's
something the gadget/function driver must guarantee that it's
always balanced.

In order to balance the calls, just make sure the endpoint
was enabled before by means of checking the validity of
driver_data.

Reported-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Felipe Balbi committed Feb 23, 2015
1 parent 2035772 commit 9ec36f7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/usb/gadget/function/f_phonet.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,10 @@ static int pn_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
return -EINVAL;

spin_lock(&port->lock);
__pn_reset(f);

if (fp->in_ep->driver_data)
__pn_reset(f);

if (alt == 1) {
int i;

Expand Down

0 comments on commit 9ec36f7

Please sign in to comment.