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: Re: [CHECKER] 112 potential memory leaks in 2.5.48
Date: Wed, 5 Feb 2003 23:20:08 +1100 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.44.0302052302160.28037-100000@blackbird.intercode.com.au> (raw)
In-Reply-To: <20030205011353.GA17941@Xenon.Stanford.EDU>

On Tue, 4 Feb 2003, Andy Chou wrote:

> [BUG] /u1/acc/linux/2.5.48/net/ipv6/route.c:1583:inet6_rtm_getroute: 
> ERROR:LEAK:1556:1583:Memory leak

Here's the ipv6 fix.


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

diff -urN -X dontdiff linux-2.5.59.orig/net/ipv6/route.c linux-2.5.59.w1/net/ipv6/route.c
--- linux-2.5.59.orig/net/ipv6/route.c	Tue Nov 12 00:12:07 2002
+++ linux-2.5.59.w1/net/ipv6/route.c	Wed Feb  5 23:00:17 2003
@@ -1548,14 +1548,14 @@
 {
 	struct rtattr **rta = arg;
 	int iif = 0;
-	int err;
+	int err = -ENOBUFS;
 	struct sk_buff *skb;
 	struct flowi fl;
 	struct rt6_info *rt;
 
 	skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
 	if (skb == NULL)
-		return -ENOBUFS;
+		goto out;
 
 	/* Reserve room for dummy headers, this skb can pass
 	   through good chunk of routing engine.
@@ -1579,8 +1579,10 @@
 	if (iif) {
 		struct net_device *dev;
 		dev = __dev_get_by_index(iif);
-		if (!dev)
-			return -ENODEV;
+		if (!dev) {
+			err = -ENODEV;
+			goto out_free;
+		}
 	}
 
 	fl.oif = 0;
@@ -1597,13 +1599,19 @@
 			    fl.nl_u.ip6_u.saddr,
 			    iif,
 			    RTM_NEWROUTE, NETLINK_CB(in_skb).pid, nlh->nlmsg_seq);
-	if (err < 0)
-		return -EMSGSIZE;
+	if (err < 0) {
+		err = -EMSGSIZE;
+		goto out_free;
+	}
 
 	err = netlink_unicast(rtnl, skb, NETLINK_CB(in_skb).pid, MSG_DONTWAIT);
-	if (err < 0)
-		return err;
-	return 0;
+	if (err > 0)
+		err = 0;
+out:
+	return err;
+out_free:
+	kfree_skb(skb);
+	goto out;	
 }
 
 void inet6_rt_notify(int event, struct rt6_info *rt)



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

Thread overview: 15+ 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 ` [PATCH] " James Morris
2003-02-07  9:24   ` David S. Miller
2003-02-05 12:20 ` James Morris [this message]
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
2003-02-05 17:48 Steven French

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.0302052302160.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®