[media] drivers/staging/media/easycap/easycap_main.c: add missing usb_free_urb
authorJulia Lawall <Julia.Lawall@lip6.fr>
Tue, 24 Jul 2012 14:06:09 +0000 (11:06 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 31 Jul 2012 00:05:45 +0000 (21:05 -0300)
Add missing usb_free_urb on failure path after usb_alloc_urb.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@km exists@
local idexpression e;
expression e1,e2,e3;
type T,T1;
identifier f;
@@

* e = usb_alloc_urb(...)
... when any
    when != e = e1
    when != e1 = (T)e
    when != e1(...,(T)e,...)
    when != &e->f
if(...) { ... when != e2(...,(T1)e,...)
                 when != e3 = e
                 when forall
(
             return <+...e...+>;
|
*             return ...;
) }
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/staging/media/easycap/easycap_main.c

index aed9537..19d2d9d 100644 (file)
@@ -3083,6 +3083,7 @@ static int create_video_urbs(struct easycap *peasycap)
                peasycap->allocation_video_urb += 1;
                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;
                }