From: Jesper Juhl Date: Sun, 29 Jan 2012 19:55:28 +0000 (-0300) Subject: [media] easycap: Fix mem leak in easycap_usb_probe() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9fa728ea35501fb5cd56880839ad867265c61822;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [media] easycap: Fix mem leak in easycap_usb_probe() If allocating 'pdata_urb' fails, the function will return -ENOMEM without freeing the memory allocated, just a few lines above, for 'purb' and will leak that memory when 'purb' goes out of scope. This patch resolves the leak by freeing the allocated storage with usb_free_urb() before the return. Signed-off-by: Jesper Juhl Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/staging/media/easycap/easycap_main.c b/drivers/staging/media/easycap/easycap_main.c index 8ff5f38ea196..3d439b790cc6 100644 --- a/drivers/staging/media/easycap/easycap_main.c +++ b/drivers/staging/media/easycap/easycap_main.c @@ -3825,6 +3825,7 @@ static int easycap_usb_probe(struct usb_interface *intf, /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ pdata_urb = kzalloc(sizeof(struct data_urb), GFP_KERNEL); if (!pdata_urb) { + usb_free_urb(purb); SAM("ERROR: Could not allocate struct data_urb.\n"); return -ENOMEM; }