Re: [IPV6] Fix refcnt leak in addrconf regen timer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In article <20030709125034.GA25951@gondor.apana.org.au> (at Wed, 9 Jul 2003 22:50:34 +1000), Herbert Xu <herbert@gondor.apana.org.au> says:

> On Wed, Jul 09, 2003 at 09:44:50PM +0900, YOSHIFUJI Hideaki / ?$B5HF#1QL@ wrote:
> > 
> > Hmm, please try this.
> 
> Thanks.  But you still need the rest of the patch as otherwise every time
> the regen timer is run it will add an extra hold on idev.
> 
> So here is the updated patch.

How about this?

Index: net/ipv6/addrconf.c
===================================================================
RCS file: /home/cvs/linux-2.5/net/ipv6/addrconf.c,v
retrieving revision 1.44
diff -u -r1.44 addrconf.c
--- net/ipv6/addrconf.c	1 Jul 2003 16:42:06 -0000	1.44
+++ net/ipv6/addrconf.c	9 Jul 2003 11:55:07 -0000
@@ -368,6 +368,7 @@
 				dev, dev->name);
 			ndev->cnf.use_tempaddr = -1;
 		} else {
+			in6_dev_hold(ndev);
 			__ipv6_regen_rndid(ndev);
 		}
 #endif
@@ -1122,9 +1123,6 @@
 	sg[1].offset = ((long) eui64 & ~PAGE_MASK);
 	sg[1].length = 8;
 
-	if (!del_timer(&idev->regen_timer))
-		in6_dev_hold(idev);
-
 	dev = idev->dev;
 
 	if (ipv6_generate_eui64(eui64, dev)) {
@@ -1907,6 +1905,27 @@
 	/* Step 3: clear address list */
 
 	write_lock_bh(&idev->lock);
+#ifdef CONFIG_IPV6_PRIVACY
+	if (how == 1 && del_timer(&idev->regen_timer))
+		in6_dev_put(idev);
+
+	/* clear tempaddr list */
+	while ((ifa = idev->tempaddr_list) != NULL) {
+		idev->tempaddr_list = ifa->tmp_next;
+		ifa->tmp_next = NULL;
+		ifa->dead = 1;
+		write_unlock_bh(&idev->lock);
+		spin_lock_bh(&ifa->lock);
+		
+		if (ifa->ifpub) {
+			in6_ifa_put(ifa->ifpub);
+			ifa->ifpub = NULL;
+		}
+		spin_unlock_bh(&ifa->lock);
+		in6_ifa_put(ifa);
+		write_lock_bh(&idev->lock);
+	}
+#endif
 	while ((ifa = idev->addr_list) != NULL) {
 		idev->addr_list = ifa->if_next;
 		ifa->if_next = NULL;

-- 
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux