[PATCH] Re: [CHECKER] 112 potential memory leaks in 2.5.48

From: James Morris (jmorris@intercode.com.au)
Date: Wed Feb 05 2003 - 07:19:14 EST


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)

- 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/



This archive was generated by hypermail 2b29 : Fri Feb 07 2003 - 22:00:17 EST