svn commit: r302083 - head/sys/net

Bjoern A. Zeeb bz at FreeBSD.org
Wed Jun 22 11:45:32 UTC 2016


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


More information about the svn-src-head mailing list