• J
    drivers/video/gbefb.c: eliminate memory leak · f3569106
    Julia Lawall 提交于
    This code is preceded by a call to framebuffer_alloc, which allocates
    memory, so this memory should be freed before leaving the function in an
    error case.  out_release_framebuffer just frees the frame buffer and
    returns.
    
    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 = framebuffer_alloc(...);
    <... when != x
         when != true (x == NULL || ...)
         when != if (...) { <+...x...+> }
         when != I (...) { <+...x...+> }
    (
     x == NULL
    |
     x == E
    |
     x->f1
    )
    ...>
    * return ...;
    // </smpl>
    Signed-off-by: NJulia Lawall <julia@diku.dk>
    Cc: Ralf Baechle <ralf@linux-mips.org>
    Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
    Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
    f3569106
gbefb.c 32.7 KB