]> git.hungrycats.org Git - linux/commitdiff
usb: gadget: function: phonet: balance usb_ep_disable calls
authorFelipe Balbi <balbi@ti.com>
Mon, 2 Feb 2015 22:24:17 +0000 (16:24 -0600)
committerJiri Slaby <jslaby@suse.cz>
Thu, 12 Mar 2015 16:31:24 +0000 (17:31 +0100)
commit 9ec36f7fe20ef919cc15171e1da1b6739222541a 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: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/usb/gadget/f_phonet.c

index eb3aa817a662616810a4c9d9c6232c1e8f2a2e2f..74ff54141416d308a168d1d38d45510cd2310097 100644 (file)
@@ -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;