Skip to contentSkip to conversation

ipv6 addrconf: Fix memory leak when deleting addresses

PATCH YOSHIFUJI Hideaki / 吉藤英明 1 participant 2 messages Jun 5, 2008 – Jun 11, 2008 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

In article <[email protected]> (at Thu, 5 Jun 2008 01:49:34 +0200), Thomas Graf <[email protected]> says:

Quoted 1 line

ip6_del_rt() may fail in which case the dst/route is not released.

If prefix is ::/64 and ...

The only case ip6_del_rt() does not call dst_release() is when rt is ip6_null_entry. In that case we should skip whole the logic in the caller, anyway.

Note: it might be better to release refcnt when ip6_del_rt() returns.

net/ipv6/addrconf.c +2 -2
index 3a83557..d8ce0d7 100644
@@ -772,7 +772,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
 		ipv6_addr_prefix(&prefix, &ifp->addr, ifp->prefix_len);
 		rt = rt6_lookup(net, &prefix, NULL, ifp->idev->dev->ifindex, 1);
 
-		if (rt && ((rt->rt6i_flags & (RTF_GATEWAY | RTF_DEFAULT)) == 0)) {
+		if (rt && ((rt->rt6i_flags & (RTF_REJECT | RTF_GATEWAY | RTF_DEFAULT)) == 0)) {
 			if (onlink == 0) {
 				ip6_del_rt(rt);
 				rt = NULL;
@@ -1789,7 +1789,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len)
 		rt = rt6_lookup(dev_net(dev), &pinfo->prefix, NULL,
 				dev->ifindex, 1);
 
-		if (rt && ((rt->rt6i_flags & (RTF_GATEWAY | RTF_DEFAULT)) == 0)) {
+		if (rt && ((rt->rt6i_flags & (RTF_REJECT | RTF_GATEWAY | RTF_DEFAULT)) == 0)) {
 			/* Autoconf prefix route */
 			if (valid_lft == 0) {
 				ip6_del_rt(rt);
Signature · 2 lines
YOSHIFUJI Hideaki @ USAGI Project  <[email protected]>
GPG-FP  : 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA
#2 lore raw

In article <[email protected]> (at Thu, 05 Jun 2008 11:26:46 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 <[email protected]> says:

Quoted 9 lines

In article <[email protected]> (at Thu, 5 Jun 2008 01:49:34 +0200), Thomas Graf <[email protected]> says:

Quoted 1 line

ip6_del_rt() may fail in which case the dst/route is not released.

If prefix is ::/64 and ...

The only case ip6_del_rt() does not call dst_release() is when rt is ip6_null_entry. In that case we should skip whole the logic in the caller, anyway.

Well, actually, I've found that this cannot even happen because rt6_lookup() return NULL whenever it hits ipv6_null_entry.

So, I'm going to drop this.

--yoshfuji