OSDN Git Service

drivers/ata/sata_dwc_460ex.c: add missing kfree
authorJulia Lawall <julia@diku.dk>
Mon, 8 Aug 2011 11:17:57 +0000 (13:17 +0200)
committerJeff Garzik <jgarzik@redhat.com>
Fri, 19 Aug 2011 03:58:11 +0000 (23:58 -0400)
commita081da630d64acf132b2db1043c586b993d49da7
treeed79ad186b940c18a298054a1a1e1ef431e8bc3f
parente39c75cf3e045c2fb3988770b207dfd09c30d4ac
drivers/ata/sata_dwc_460ex.c: add missing kfree

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>
@exists@
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
x->fl
...>
(
if (x == NULL) S1
|
if (...) { ... when != x
               when forall
(
 return \(0\|<+...x...+>\|ptr\);
|
* return ...;
)
}
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
drivers/ata/sata_dwc_460ex.c