From 3de0b917bfc51691db7e7454c1decc8f7dc59697 Mon Sep 17 00:00:00 2001 From: emaste Date: Mon, 21 May 2018 13:08:44 +0000 Subject: [PATCH] Pair CURVNET_SET and CURVNET_RESTORE in a block Per vnet(9), CURVNET_SET and CURVNET_RESTORE cannot be used as a single statement for a conditional and CURVNET_RESTORE must be in the same block as CURVNET_SET (or a subblock). Reviewed by: andrew Sponsored by: The FreeBSD Foundation --- sys/netinet/in_mcast.c | 22 +++++++++++++--------- sys/netinet6/in6_mcast.c | 22 +++++++++++++--------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c index a37f64f1a89d..b6f0f367abcd 100644 --- a/sys/netinet/in_mcast.c +++ b/sys/netinet/in_mcast.c @@ -663,15 +663,17 @@ inm_release(struct in_multi *inm) /* XXX this access is not covered by IF_ADDR_LOCK */ CTR2(KTR_IGMPV3, "%s: purging ifma %p", __func__, ifma); - if (ifp) + if (ifp != NULL) { CURVNET_SET(ifp->if_vnet); - inm_purge(inm); - free(inm, M_IPMADDR); - - if_delmulti_ifma_flags(ifma, 1); - if (ifp) { + inm_purge(inm); + free(inm, M_IPMADDR); + if_delmulti_ifma_flags(ifma, 1); CURVNET_RESTORE(); if_rele(ifp); + } else { + inm_purge(inm); + free(inm, M_IPMADDR); + if_delmulti_ifma_flags(ifma, 1); } } @@ -1677,11 +1679,13 @@ inp_gcmoptions(epoch_context_t ctx) imf_leave(imf); inm = imo->imo_membership[idx]; ifp = inm->inm_ifp; - if (ifp) + if (ifp != NULL) { CURVNET_SET(ifp->if_vnet); - (void)in_leavegroup(inm, imf); - if (ifp) + (void)in_leavegroup(inm, imf); CURVNET_RESTORE(); + } else { + (void)in_leavegroup(inm, imf); + } if (imf) imf_purge(imf); } diff --git a/sys/netinet6/in6_mcast.c b/sys/netinet6/in6_mcast.c index ba23b1d85de4..091d4d31b347 100644 --- a/sys/netinet6/in6_mcast.c +++ b/sys/netinet6/in6_mcast.c @@ -539,15 +539,17 @@ in6m_release(struct in6_multi *inm) KASSERT(ifma->ifma_protospec == NULL, ("%s: ifma_protospec != NULL", __func__)); - if (ifp) + if (ifp != NULL) { CURVNET_SET(ifp->if_vnet); - in6m_purge(inm); - free(inm, M_IP6MADDR); - - if_delmulti_ifma_flags(ifma, 1); - if (ifp) { + in6m_purge(inm); + free(inm, M_IP6MADDR); + if_delmulti_ifma_flags(ifma, 1); CURVNET_RESTORE(); if_rele(ifp); + } else { + in6m_purge(inm); + free(inm, M_IP6MADDR); + if_delmulti_ifma_flags(ifma, 1); } } @@ -1639,11 +1641,13 @@ inp_gcmoptions(epoch_context_t ctx) im6f_leave(imf); inm = imo->im6o_membership[idx]; ifp = inm->in6m_ifp; - if (ifp) + if (ifp != NULL) { CURVNET_SET(ifp->if_vnet); - (void)in6_leavegroup(inm, imf); - if (ifp) + (void)in6_leavegroup(inm, imf); CURVNET_RESTORE(); + } else { + (void)in6_leavegroup(inm, imf); + } if (imf) im6f_purge(imf); }