Commit 3de70a7f authored by Felipe Balbi's avatar Felipe Balbi Committed by Luis Henriques

usb: gadget: function: phonet: balance usb_ep_disable calls

commit 9ec36f7f upstream.

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: default avatarPali Rohár <pali.rohar@gmail.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
[ luis: backported to 3.16:
  - file rename: drivers/usb/gadget/function/f_phonet.c ->
    drivers/usb/gadget/f_phonet.c ]
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 5ec97889
...@@ -417,7 +417,10 @@ static int pn_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -417,7 +417,10 @@ static int pn_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
return -EINVAL; return -EINVAL;
spin_lock(&port->lock); spin_lock(&port->lock);
__pn_reset(f);
if (fp->in_ep->driver_data)
__pn_reset(f);
if (alt == 1) { if (alt == 1) {
int i; int i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment