diff options
author | Julia Lawall <julia@diku.dk> | 2010-08-24 00:38:33 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-08-25 19:36:49 -0400 |
commit | 8d34e7d6f38fce1c7e595404295494cd1eaba3eb (patch) | |
tree | d8b651d02724411e1b3acd5c9ad5801f9a6b83a5 /drivers/net/irda/via-ircc.c | |
parent | 21ff2929edc89397cc4c621d3c3f842994640acd (diff) |
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>
Diffstat (limited to 'drivers/net/irda/via-ircc.c')
-rw-r--r-- | drivers/net/irda/via-ircc.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c index b0a6cd815be1..67c0ad42d818 100644 --- a/drivers/net/irda/via-ircc.c +++ b/drivers/net/irda/via-ircc.c | |||
@@ -1182,12 +1182,13 @@ F01_E */ | |||
1182 | 1182 | ||
1183 | skb = dev_alloc_skb(len + 1 - 4); | 1183 | skb = dev_alloc_skb(len + 1 - 4); |
1184 | /* | 1184 | /* |
1185 | * if frame size,data ptr,or skb ptr are wrong ,the get next | 1185 | * if frame size, data ptr, or skb ptr are wrong, then get next |
1186 | * entry. | 1186 | * entry. |
1187 | */ | 1187 | */ |
1188 | if ((skb == NULL) || (skb->data == NULL) || | 1188 | if ((skb == NULL) || (skb->data == NULL) || |
1189 | (self->rx_buff.data == NULL) || (len < 6)) { | 1189 | (self->rx_buff.data == NULL) || (len < 6)) { |
1190 | self->netdev->stats.rx_dropped++; | 1190 | self->netdev->stats.rx_dropped++; |
1191 | kfree_skb(skb); | ||
1191 | return TRUE; | 1192 | return TRUE; |
1192 | } | 1193 | } |
1193 | skb_reserve(skb, 1); | 1194 | skb_reserve(skb, 1); |