From owner-svn-src-all@freebsd.org Wed Jun 22 11:45:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 02381A7A268; Wed, 22 Jun 2016 11:45:32 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C34351D28; Wed, 22 Jun 2016 11:45:31 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5MBjU9a078656; Wed, 22 Jun 2016 11:45:30 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5MBjUg1078655; Wed, 22 Jun 2016 11:45:30 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201606221145.u5MBjUg1078655@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Wed, 22 Jun 2016 11:45:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302083 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jun 2016 11:45:32 -0000 Author: bz Date: Wed Jun 22 11:45:30 2016 New Revision: 302083 URL: https://svnweb.freebsd.org/changeset/base/302083 Log: After r302054 unloading an network interface driver on a kernel without VIMAGE support would dereference a NULL point unconditionally leading to a panic. Wrap the entire VIMAGE related code with #ifdefs rather than just the decision making part to save an extra bit of resources. Reported by: np Sponsored by: The FreeBSD Foundation MFC After: 13 days Approved by: re (marius) Modified: head/sys/net/if.c Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Wed Jun 22 11:38:26 2016 (r302082) +++ head/sys/net/if.c Wed Jun 22 11:45:30 2016 (r302083) @@ -931,10 +931,13 @@ if_detach_internal(struct ifnet *ifp, in int i; struct domain *dp; struct ifnet *iter; - int found = 0, shutdown; + int found = 0; +#ifdef VIMAGE + int shutdown; shutdown = (ifp->if_vnet->vnet_state > SI_SUB_VNET && ifp->if_vnet->vnet_state < SI_SUB_VNET_DONE) ? 1 : 0; +#endif IFNET_WLOCK(); TAILQ_FOREACH(iter, &V_ifnet, if_link) if (iter == ifp) { @@ -987,6 +990,7 @@ if_detach_internal(struct ifnet *ifp, in if_down(ifp); +#ifdef VIMAGE /* * On VNET shutdown abort here as the stack teardown will do all * the work top-down for us. @@ -1001,6 +1005,7 @@ if_detach_internal(struct ifnet *ifp, in */ goto finish_vnet_shutdown; } +#endif /* * At this point we are not tearing down a VNET and are either @@ -1066,7 +1071,9 @@ if_detach_internal(struct ifnet *ifp, in rt_flushifroutes(ifp); +#ifdef VIMAGE finish_vnet_shutdown: +#endif /* * We cannot hold the lock over dom_ifdetach calls as they might * sleep, for example trying to drain a callout, thus open up the