Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Nov 2012 07:12:09 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r243648 - head/sys/dev/ath
Message-ID:  <201211280712.qAS7C9Lr064014@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Wed Nov 28 07:12:08 2012
New Revision: 243648
URL: http://svnweb.freebsd.org/changeset/base/243648

Log:
  Call if_free() with the correct vnet context if and only if ifp_vnet
  isn't NULL.
  
  If the attach fails prematurely and there's no if_vnet context, calling
  CURVNET_SET(ifp->if_vnet) is going to dereference a NULL pointer.

Modified:
  head/sys/dev/ath/if_ath.c

Modified: head/sys/dev/ath/if_ath.c
==============================================================================
--- head/sys/dev/ath/if_ath.c	Wed Nov 28 06:55:34 2012	(r243647)
+++ head/sys/dev/ath/if_ath.c	Wed Nov 28 07:12:08 2012	(r243648)
@@ -918,11 +918,16 @@ bad2:
 bad:
 	if (ah)
 		ath_hal_detach(ah);
-	if (ifp != NULL) {
+
+	/*
+	 * To work around scoping issues with CURVNET_SET/CURVNET_RESTORE..
+	 */
+	if (ifp != NULL && ifp->if_vnet) {
 		CURVNET_SET(ifp->if_vnet);
 		if_free(ifp);
 		CURVNET_RESTORE();
-	}
+	} else if (ifp != NULL)
+		if_free(ifp);
 	sc->sc_invalid = 1;
 	return error;
 }



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