mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Morris <jmorris@intercode.com.au>
To: Andy Chou <acc@CS.Stanford.EDU>
Cc: linux-kernel@vger.kernel.org, <mc@CS.Stanford.EDU>,
	"David S. Miller" <davem@redhat.com>, <kuznet@ms2.inr.ac.ru>
Subject: [PATCH] Re: [CHECKER] 112 potential memory leaks in 2.5.48
Date: Wed, 5 Feb 2003 23:19:14 +1100 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.44.0302052259590.28037-100000@blackbird.intercode.com.au> (raw)
In-Reply-To: <20030205011353.GA17941@Xenon.Stanford.EDU>

On Tue, 4 Feb 2003, Andy Chou wrote:

> [BUG] [GEM] The case where __dev_get_by_index() returns 0, followed by goto out.
> /u1/acc/linux/2.5.48/net/ipv4/route.c:2229:inet_rtm_getroute: 
> ERROR:LEAK:2166:2229:Memory leak

Here's a fix for 2.5.59.

- James
-- 
James Morris
<jmorris@intercode.com.au>

diff -urN -X dontdiff linux-2.5.59.orig/net/ipv4/route.c linux-2.5.59.w1/net/ipv4/route.c
--- linux-2.5.59.orig/net/ipv4/route.c	Thu Jan 16 22:51:35 2003
+++ linux-2.5.59.w1/net/ipv4/route.c	Wed Feb  5 22:51:48 2003
@@ -2288,7 +2288,7 @@
 		struct net_device *dev = __dev_get_by_index(iif);
 		err = -ENODEV;
 		if (!dev)
-			goto out;
+			goto out_free;
 		skb->protocol	= htons(ETH_P_IP);
 		skb->dev	= dev;
 		local_bh_disable();
@@ -2307,10 +2307,8 @@
 		fl.oif = oif;
 		err = ip_route_output_key(&rt, &fl);
 	}
-	if (err) {
-		kfree_skb(skb);
-		goto out;
-	}
+	if (err)
+		goto out_free;
 
 	skb->dst = &rt->u.dst;
 	if (rtm->rtm_flags & RTM_F_NOTIFY)
@@ -2321,16 +2319,20 @@
 	err = rt_fill_info(skb, NETLINK_CB(in_skb).pid, nlh->nlmsg_seq,
 				RTM_NEWROUTE, 0);
 	if (!err)
-		goto out;
+		goto out_free;
 	if (err < 0) {
 		err = -EMSGSIZE;
-		goto out;
+		goto out_free;
 	}
 
 	err = netlink_unicast(rtnl, skb, NETLINK_CB(in_skb).pid, MSG_DONTWAIT);
 	if (err > 0)
 		err = 0;
 out:	return err;
+
+out_free:
+	kfree_skb(skb);
+	goto out;
 }
 
 int ip_rt_dump(struct sk_buff *skb,  struct netlink_callback *cb)



  parent reply	other threads:[~2003-02-05 12:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-05  1:13 Andy Chou
2003-02-05  2:37 ` Rik van Riel
2003-02-05  2:42   ` [PATCH] " Rik van Riel
2003-02-05 16:19     ` James Bottomley
2003-02-05  6:06 ` Jochen Friedrich
2003-02-05 12:19 ` James Morris [this message]
2003-02-07  9:24   ` [PATCH] " David S. Miller
2003-02-05 12:20 ` James Morris
2003-02-07  9:25   ` David S. Miller
2003-02-05 18:16 ` Steve Lord
2003-02-05 23:48 ` Greg KH
2003-02-06  0:21   ` Andy Chou
2003-02-06  0:26 ` Greg KH
2003-02-06  2:26 ` Greg KH

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.44.0302052259590.28037-100000@blackbird.intercode.com.au \
    --to=jmorris@intercode.com.au \
    --cc=acc@CS.Stanford.EDU \
    --cc=davem@redhat.com \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mc@CS.Stanford.EDU \
    /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®