mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
To: David Yu Chen <dychen@stanford.edu>
Cc: linux-kernel@vger.kernel.org, mc@cs.stanford.edu,
	davem@redhat.com, netdev@oss.sgi.com
Subject: Re: [CHECKER] 32 Memory Leaks on Error Paths
Date: Tue, 16 Sep 2003 11:07:48 +0200	[thread overview]
Message-ID: <20030916090748.GE27703@wohnheim.fh-wedel.de> (raw)
In-Reply-To: <200309160435.h8G4ZkQM009953@elaine4.Stanford.EDU>

On Mon, 15 September 2003 21:35:46 -0700, David Yu Chen wrote:
> 
> [FILE:  2.6.0-test5/net/ipv4/igmp.c]
> [FUNC:  igmpv3_newpack]
> [LINES: 274-284]
> [VAR:   skb]
>  269:	struct sk_buff *skb;
>  270:	struct rtable *rt;
>  271:	struct iphdr *pip;
>  272:	struct igmpv3_report *pig;
>  273:
> START -->
>  274:	skb = alloc_skb(size + dev->hard_header_len + 15, GFP_ATOMIC);
>  275:	if (skb == NULL)
>  276:		return 0;
>  277:
>  278:	{
>  279:		struct flowi fl = { .oif = dev->ifindex,
>  280:				    .nl_u = { .ip4_u = {
>  281:				    .daddr = IGMPV3_ALL_MCR } },
>  282:				    .proto = IPPROTO_IGMP };
>  283:		if (ip_route_output_key(&rt, &fl))
> END -->
>  284:			return 0;
>  285:	}
>  286:	if (rt->rt_src == 0) {
>  287:		ip_rt_put(rt);
>  288:		return 0;
>  289:	}

Looks valid.  And since skb isn't really needed until after these
returns, moving four lines down a bit fixes the problem.

Davem, is this correct?

Jörn

-- 
Data dominates. If you've chosen the right data structures and organized
things well, the algorithms will almost always be self-evident. Data
structures, not algorithms, are central to programming.
-- Rob Pike

--- linux-2.6.0-test3/net/ipv4/igmp.c~igmp_memleak	2003-07-15 23:09:02.000000000 +0200
+++ linux-2.6.0-test3/net/ipv4/igmp.c	2003-09-16 10:29:47.000000000 +0200
@@ -70,6 +70,8 @@
  *		Alexey Kuznetsov:	Accordance to igmp-v2-06 draft.
  *		David L Stevens:	IGMPv3 support, with help from
  *					Vinay Kulkarni
+ *		Jörn Engel:		Fix memleak in igmpv3_newpack, reported
+ *					by David Yu Chen (stanford checker)
  */
 
 
@@ -271,10 +273,6 @@
 	struct iphdr *pip;
 	struct igmpv3_report *pig;
 
-	skb = alloc_skb(size + dev->hard_header_len + 15, GFP_ATOMIC);
-	if (skb == NULL)
-		return 0;
-
 	{
 		struct flowi fl = { .oif = dev->ifindex,
 				    .nl_u = { .ip4_u = {
@@ -288,6 +286,10 @@
 		return 0;
 	}
 
+	skb = alloc_skb(size + dev->hard_header_len + 15, GFP_ATOMIC);
+	if (skb == NULL)
+		return 0;
+
 	skb->dst = &rt->u.dst;
 	skb->dev = dev;
 

  parent reply	other threads:[~2003-09-16  9:08 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-16  4:35 David Yu Chen
2003-09-16  6:40 ` Neil Brown
2003-09-16  6:55 ` Jörn Engel
2003-09-16  7:21   ` [PATCH] fix memleak in fs/jffs2/scan.c (was: re: [CHECKER] 32 Memory Leaks on Error Paths) Jörn Engel
2003-09-16  7:32   ` [CHECKER] 32 Memory Leaks on Error Paths Jörn Engel
2003-09-16  8:51   ` Jörn Engel
2003-09-16 14:52   ` Timothy Miller
2003-09-16 15:02     ` Wade
2003-09-16 15:04     ` Valdis.Kletnieks
2003-09-16 15:04     ` Nick Piggin
2003-09-16  8:45 ` Wade
2003-09-16  8:56   ` Jörn Engel
2003-09-16 12:10   ` Andries Brouwer
2003-09-16  9:07 ` Jörn Engel [this message]
2003-09-20  7:58   ` David S. Miller
2003-09-16  9:48 ` [PATCH] bttv-risc.c (was: Re: [CHECKER] 32 Memory Leaks on Error Paths) Wade
2003-09-16 10:18 ` [PATCH] fix memleak in emu10k1/midi.c " Wade
2003-09-16 12:03 ` [CHECKER] 32 Memory Leaks on Error Paths Andries Brouwer
2003-09-19 23:03 ` Chris Wright
2003-09-19 23:04 ` Chris Wright
2003-09-19 23:04 ` Chris Wright
2003-09-19 23:04 ` Chris Wright
2003-09-23 13:15   ` Stephen Smalley
2003-09-23 18:02     ` Chris Wright
2003-09-22 22:54 ` Chris Wright
2003-09-22 22:55 ` Chris Wright
2003-09-22 22:55 ` Chris Wright
2003-09-23 20:13 ` Chris Wright
2003-09-23 20:25   ` Greg KH
2003-09-23 21:38     ` Chris Wright
2003-09-23 22:14     ` Chris Wright
2003-09-24  0:17       ` Greg KH
2003-09-23 20:14 ` Chris Wright
2003-09-23 20:14 ` Chris Wright
2003-09-23 20:21   ` Jean Tourrilhes
2003-09-23 20:24     ` Chris Wright
2003-09-23 20:14 ` Chris Wright
2003-09-23 20:15 ` Chris Wright
2003-09-24  7:08 ` David Howells
     [not found] <20030923140503.N20572@osdlab.pdx.osdl.net>
2003-09-24  4:13 ` Pete Zaitcev
2003-09-24 12:49   ` Alan Cox
2003-09-24 16:38     ` Pete Zaitcev
2003-09-29 17:48   ` Marcelo Tosatti
2003-09-29 17:54     ` Pete Zaitcev
2003-11-06  0:58     ` Pete Zaitcev

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=20030916090748.GE27703@wohnheim.fh-wedel.de \
    --to=joern@wohnheim.fh-wedel.de \
    --cc=davem@redhat.com \
    --cc=dychen@stanford.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mc@cs.stanford.edu \
    --cc=netdev@oss.sgi.com \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®