Skip to content

Commit

Permalink
net: tcp: fix rtable leak in tcp_is_local[6]
Browse files Browse the repository at this point in the history
ip_rt_put/ip6_rt_put call is missed after route lookup routine.
So if lookup returns ok, rtable leak will happen.

Change-Id: Ica137043879b4305b70401cf7e8efda24405e3ff
Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
  • Loading branch information
liping.zhang authored and sultanqasim committed Mar 20, 2016
1 parent 5e9bfaa commit dd86c42
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3501,16 +3501,24 @@ void __init tcp_init(void)
static int tcp_is_local(struct net *net, __be32 addr) {
struct rtable *rt;
struct flowi4 fl4 = { .daddr = addr };
int is_local;
rt = ip_route_output_key(net, &fl4);
if (IS_ERR_OR_NULL(rt))
return 0;
return rt->dst.dev && (rt->dst.dev->flags & IFF_LOOPBACK);

is_local = rt->dst.dev && (rt->dst.dev->flags & IFF_LOOPBACK);
ip_rt_put(rt);
return is_local;
}

#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
static int tcp_is_local6(struct net *net, struct in6_addr *addr) {
struct rt6_info *rt6 = rt6_lookup(net, addr, addr, 0, 0);
return rt6 && rt6->dst.dev && (rt6->dst.dev->flags & IFF_LOOPBACK);
int is_local;

is_local = rt6 && rt6->dst.dev && (rt6->dst.dev->flags & IFF_LOOPBACK);
ip6_rt_put(rt6);
return is_local;
}
#endif

Expand Down

0 comments on commit dd86c42

Please sign in to comment.