Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Jul 2012 08:58:30 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r238573 - head/sys/netinet
Message-ID:  <201207180858.q6I8wUYB048160@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Wed Jul 18 08:58:30 2012
New Revision: 238573
URL: http://svn.freebsd.org/changeset/base/238573

Log:
  Plug a reference leak: before doing 'goto again' we need to unref
  ia->ia_ifa if there is any.
  
  Submitted by:	Andrey Zonov <andrey zonov.org>

Modified:
  head/sys/netinet/ip_output.c

Modified: head/sys/netinet/ip_output.c
==============================================================================
--- head/sys/netinet/ip_output.c	Wed Jul 18 08:41:00 2012	(r238572)
+++ head/sys/netinet/ip_output.c	Wed Jul 18 08:58:30 2012	(r238573)
@@ -124,7 +124,7 @@ ip_output(struct mbuf *m, struct mbuf *o
 	int n;	/* scratchpad */
 	int error = 0;
 	struct sockaddr_in *dst;
-	struct in_ifaddr *ia = NULL;
+	struct in_ifaddr *ia;
 	int isbroadcast, sw_csum;
 	struct route iproute;
 	struct rtentry *rte;	/* cache for ro->ro_rt */
@@ -198,6 +198,7 @@ ip_output(struct mbuf *m, struct mbuf *o
 
 	dst = (struct sockaddr_in *)&ro->ro_dst;
 again:
+	ia = NULL;
 	/*
 	 * If there is a cached route,
 	 * check that it is to the same destination
@@ -533,8 +534,11 @@ sendit:
 #endif
 			error = netisr_queue(NETISR_IP, m);
 			goto done;
-		} else
+		} else {
+			if (ia != NULL)
+				ifa_free(&ia->ia_ifa);
 			goto again;	/* Redo the routing table lookup. */
+		}
 	}
 
 #ifdef IPFIREWALL_FORWARD
@@ -564,6 +568,8 @@ sendit:
 		bcopy((fwd_tag+1), dst, sizeof(struct sockaddr_in));
 		m->m_flags |= M_SKIP_FIREWALL;
 		m_tag_delete(m, fwd_tag);
+		if (ia != NULL)
+			ifa_free(&ia->ia_ifa);
 		goto again;
 	}
 #endif /* IPFIREWALL_FORWARD */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207180858.q6I8wUYB048160>