Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Nov 2016 19:23:48 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r308694 - head/sys/net
Message-ID:  <201611151923.uAFJNmJC016900@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Tue Nov 15 19:23:48 2016
New Revision: 308694
URL: https://svnweb.freebsd.org/changeset/base/308694

Log:
  Plug a lock leak in sysctl_ifmalist().
  
  Fix style in the local variable declarations.
  
  PR:		214542
  MFC after:	1 week

Modified:
  head/sys/net/rtsock.c

Modified: head/sys/net/rtsock.c
==============================================================================
--- head/sys/net/rtsock.c	Tue Nov 15 19:09:36 2016	(r308693)
+++ head/sys/net/rtsock.c	Tue Nov 15 19:23:48 2016	(r308694)
@@ -1773,13 +1773,15 @@ done:
 static int
 sysctl_ifmalist(int af, struct walkarg *w)
 {
-	struct ifnet *ifp;
-	struct ifmultiaddr *ifma;
-	struct	rt_addrinfo info;
-	int	len, error = 0;
+	struct rt_addrinfo info;
 	struct ifaddr *ifa;
+	struct ifmultiaddr *ifma;
+	struct ifnet *ifp;
+	int error, len;
 
+	error = 0;
 	bzero((caddr_t)&info, sizeof(info));
+
 	IFNET_RLOCK_NOSLEEP();
 	TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
 		if (w->w_arg && w->w_arg != ifp->if_index)
@@ -1799,7 +1801,7 @@ sysctl_ifmalist(int af, struct walkarg *
 			    ifma->ifma_lladdr : NULL;
 			error = rtsock_msg_buffer(RTM_NEWMADDR, &info, w, &len);
 			if (error != 0)
-				goto done;
+				break;
 			if (w->w_req && w->w_tmem) {
 				struct ifma_msghdr *ifmam;
 
@@ -1808,15 +1810,14 @@ sysctl_ifmalist(int af, struct walkarg *
 				ifmam->ifmam_flags = 0;
 				ifmam->ifmam_addrs = info.rti_addrs;
 				error = SYSCTL_OUT(w->w_req, w->w_tmem, len);
-				if (error) {
-					IF_ADDR_RUNLOCK(ifp);
-					goto done;
-				}
+				if (error != 0)
+					break;
 			}
 		}
 		IF_ADDR_RUNLOCK(ifp);
+		if (error != 0)
+			break;
 	}
-done:
 	IFNET_RUNLOCK_NOSLEEP();
 	return (error);
 }



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