From dff78447a4b05687b60fca906a9323f21521aaee Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Mon, 13 Apr 2015 01:55:42 +0000 Subject: [PATCH] Fix a possible refcount leak in regen_tmpaddr(). public_ifa6 may be set to NULL after taking a reference to a previous address list element. Instead, only take the reference after leaving the loop but before releasing the address list lock. Differential Revision: https://reviews.freebsd.org/D2253 Reviewed by: ae MFC after: 2 weeks --- sys/netinet6/nd6.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index da32f07575c..a344d6a2ae1 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -765,11 +765,10 @@ regen_tmpaddr(struct in6_ifaddr *ia6) * address with the prefix. */ if (!IFA6_IS_DEPRECATED(it6)) - public_ifa6 = it6; - - if (public_ifa6 != NULL) - ifa_ref(&public_ifa6->ia_ifa); + public_ifa6 = it6; } + if (public_ifa6 != NULL) + ifa_ref(&public_ifa6->ia_ifa); IF_ADDR_RUNLOCK(ifp); if (public_ifa6 != NULL) {