usb: gadget: f_midi: check for error on usb_ep_queue
authorFelipe F. Tonello <eu@felipetonello.com>
Fri, 18 Sep 2015 17:36:28 +0000 (18:36 +0100)
committerFelipe Balbi <balbi@ti.com>
Sun, 27 Sep 2015 15:54:31 +0000 (10:54 -0500)
f_midi is not checking whether there is an error on usb_ep_queue
request, ignoring potential problems, such as memory leaks.

Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/function/f_midi.c

index a287a48292731b2b9eda7a0294eed98dfd6b0987..9fc86d90c7bd1d390a9e0cc4bb79244675703960 100644 (file)
@@ -547,10 +547,16 @@ static void f_midi_transmit(struct f_midi *midi, struct usb_request *req)
                }
        }
 
-       if (req->length > 0)
-               usb_ep_queue(ep, req, GFP_ATOMIC);
-       else
+       if (req->length > 0) {
+               int err;
+
+               err = usb_ep_queue(ep, req, GFP_ATOMIC);
+               if (err < 0)
+                       ERROR(midi, "%s queue req: %d\n",
+                             midi->in_ep->name, err);
+       } else {
                free_ep_req(ep, req);
+       }
 }
 
 static void f_midi_in_tasklet(unsigned long data)