From bd808e3ce8fe9348fc6cbaff866f00e08fdc0421 Mon Sep 17 00:00:00 2001 From: markj Date: Tue, 22 Nov 2016 17:42:59 +0000 Subject: MFC r308694: Plug a lock leak in sysctl_ifmalist(). PR: 214542 --- sys/net/rtsock.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'sys/net') diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 91158b0..1ffb997 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1768,13 +1768,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) @@ -1794,7 +1796,7 @@ sysctl_ifmalist(int af, struct walkarg *w) 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; @@ -1803,15 +1805,14 @@ sysctl_ifmalist(int af, struct walkarg *w) 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); } -- cgit v1.1