• Julia Lawall's avatar
    drivers/net/irda: Eliminate memory leak · 8d34e7d6
    Julia Lawall authored
    dev_alloc_skb allocates some memory, so that memory should be freed before
    leaving the function in an error case.
    
    Corrected some typos in a nearby comment as well.
    
    A simplified version of the semantic match that finds this problem is:
    (http://coccinelle.lip6.fr/)
    
    // <smpl>
    @r exists@
    local idexpression x;
    expression E;
    identifier f1;
    iterator I;
    @@
    
    x = dev_alloc_skb(...);
    <... when != x
         when != true (x == NULL || ...)
         when != if (...) { <+...x...+> }
         when != I (...) { <+...x...+> }
    (
     x == NULL
    |
     x == E
    |
     x->f1
    )
    ...>
    * return ...;
    // </smpl>
    Signed-off-by: default avatarJulia Lawall <julia@diku.dk>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    8d34e7d6
via-ircc.c 41.9 KB