From: Andrzej Pietrasiewicz Date: Thu, 21 Aug 2014 14:54:45 +0000 (+0200) Subject: usb: gadget: f_uvc: fix potential memory leak X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e73798572e115f73066567f5840d4e5c21da70a8;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git usb: gadget: f_uvc: fix potential memory leak If uvc->control_buf is successfuly allocated but uvc->control_req is not, uvc->control_buf is not freed in the error recovery path. With this patch applied uvc->control_buf is freed unconditionally; if it happens to be NULL kfree on it is safe anyway. Signed-off-by: Andrzej Pietrasiewicz Acked-by: Sebastian Andrzej Siewior Signed-off-by: Laurent Pinchart Signed-off-by: Felipe Balbi --- diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c index e2a1f50bd93c..ff4340a1b4b3 100644 --- a/drivers/usb/gadget/function/f_uvc.c +++ b/drivers/usb/gadget/function/f_uvc.c @@ -720,10 +720,9 @@ error: if (uvc->video.ep) uvc->video.ep->driver_data = NULL; - if (uvc->control_req) { + if (uvc->control_req) usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); - kfree(uvc->control_buf); - } + kfree(uvc->control_buf); usb_free_all_descriptors(f); return ret;