[PATCH 1/2] usb: gadget: f_midi: fail if set_alt fails to allocate requests

Tyler Hicks tyhicks at canonical.com
Wed Aug 14 23:21:44 UTC 2019


From: "Felipe F. Tonello" <eu at felipetonello.com>

This ensures that the midi function will only work if the proper number of
IN and OUT requrests are allocated. Otherwise the function will work with less
requests then what the user wants.

Signed-off-by: Felipe F. Tonello <eu at felipetonello.com>
Signed-off-by: Felipe Balbi <balbi at ti.com>

CVE-2018-20961

(cherry picked from commit f0f1b8cac4d8d973e95f25d9ea132775fb43c5f4)
Signed-off-by: Tyler Hicks <tyhicks at canonical.com>
---
 drivers/usb/gadget/function/f_midi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c
index 5ead414586a1..89db9cd22665 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -364,9 +364,10 @@ static int f_midi_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
 		req->complete = f_midi_complete;
 		err = usb_ep_queue(midi->out_ep, req, GFP_ATOMIC);
 		if (err) {
-			ERROR(midi, "%s queue req: %d\n",
+			ERROR(midi, "%s: couldn't enqueue request: %d\n",
 				    midi->out_ep->name, err);
 			free_ep_req(midi->out_ep, req);
+			return err;
 		}
 	}
 
-- 
2.17.1




More information about the kernel-team mailing list