Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Wed, 5 Feb 2003 07:10:43 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Wed, 5 Feb 2003 07:10:43 -0500 Received: from blackbird.intercode.com.au ([203.32.101.10]:12819 "EHLO blackbird.intercode.com.au") by vger.kernel.org with ESMTP id ; Wed, 5 Feb 2003 07:10:41 -0500 Date: Wed, 5 Feb 2003 23:20:08 +1100 (EST) From: James Morris To: Andy Chou cc: linux-kernel@vger.kernel.org, , "David S. Miller" , Subject: Re: [CHECKER] 112 potential memory leaks in 2.5.48 In-Reply-To: <20030205011353.GA17941@Xenon.Stanford.EDU> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1752 Lines: 78 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 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) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/