dect
/
linux-2.6
Archived
13
0
Fork 0

drivers/net/irda: Eliminate memory leak

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: Julia Lawall <julia@diku.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Julia Lawall 2010-08-24 04:38:33 +00:00 committed by David S. Miller
parent 21ff2929ed
commit 8d34e7d6f3
1 changed files with 2 additions and 1 deletions

View File

@ -1182,12 +1182,13 @@ F01_E */
skb = dev_alloc_skb(len + 1 - 4);
/*
* if frame size,data ptr,or skb ptr are wrong ,the get next
* if frame size, data ptr, or skb ptr are wrong, then get next
* entry.
*/
if ((skb == NULL) || (skb->data == NULL) ||
(self->rx_buff.data == NULL) || (len < 6)) {
self->netdev->stats.rx_dropped++;
kfree_skb(skb);
return TRUE;
}
skb_reserve(skb, 1);