From: Julia Lawall <julia@diku.dk> To: Samuel Ortiz <samuel@sortiz.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 1/5] drivers/net/irda: Eliminate memory leak Date: Tue, 24 Aug 2010 16:38:33 +0200 (CEST) [thread overview] Message-ID: <Pine.LNX.4.64.1008241638130.15172@ask.diku.dk> (raw) From: Julia Lawall <julia@diku.dk> 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> --- drivers/net/irda/via-ircc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c index b0a6cd8..67c0ad4 100644 --- a/drivers/net/irda/via-ircc.c +++ b/drivers/net/irda/via-ircc.c @@ -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);
WARNING: multiple messages have this Message-ID (diff)
From: Julia Lawall <julia@diku.dk> To: Samuel Ortiz <samuel@sortiz.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 1/5] drivers/net/irda: Eliminate memory leak Date: Tue, 24 Aug 2010 14:38:33 +0000 [thread overview] Message-ID: <Pine.LNX.4.64.1008241638130.15172@ask.diku.dk> (raw) From: Julia Lawall <julia@diku.dk> 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> --- drivers/net/irda/via-ircc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c index b0a6cd8..67c0ad4 100644 --- a/drivers/net/irda/via-ircc.c +++ b/drivers/net/irda/via-ircc.c @@ -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);
next reply other threads:[~2010-08-24 14:38 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-08-24 14:38 Julia Lawall [this message] 2010-08-24 14:38 ` [PATCH 1/5] drivers/net/irda: Eliminate memory leak Julia Lawall 2010-08-25 23:37 ` David Miller 2010-08-25 23:37 ` David Miller [not found] <1282776100-21671-1-git-send-email-julia@diku.dk> [not found] ` <1282776100-21671-2-git-send-email-julia@diku.dk> 2010-08-25 21:57 ` Julia Lawall
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=Pine.LNX.4.64.1008241638130.15172@ask.diku.dk \ --to=julia@diku.dk \ --cc=kernel-janitors@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=netdev@vger.kernel.org \ --cc=samuel@sortiz.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.