• Julia Lawall's avatar
    drivers/ata/sata_dwc_460ex.c: add missing kfree · a081da63
    Julia Lawall authored
    Currently, error handling code in this function calls the function
    sata_dwc_port_stop, but this function has essentially no effect if hsdevp
    has not been stored in ap, which is the case throughout this function.  The
    only effect is to print a debugging message including ap->print_id.
    The code is rewritten to not call sata_dwc_port_stop, but instead to jump
    to a local label that prints the original error message and the print_id
    information.  In the case where hsdevp has been already allocated (but not
    yet stored in ap), this value is freed as well.
    A simplified version of the semantic match that finds this problem is as
    follows: (http://coccinelle.lip6.fr/)
    // <smpl>
    local idexpression x;
    statement S,S1;
    expression E;
    identifier fl;
    expression *ptr != NULL;
    x = \(kmalloc\|kzalloc\|kcalloc\)(...);
    if (x == NULL) S
    <... when != x
         when != if (...) { <+...kfree(x)...+> }
         when any
         when != true x == NULL
    if (x == NULL) S1
    if (...) { ... when != x
                   when forall
     return \(0\|<+...x...+>\|ptr\);
    * return ...;
    // </smpl>
    Signed-off-by: default avatarJulia Lawall <julia@diku.dk>
    Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
sata_dwc_460ex.c 50.3 KB