Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Aug 2017 17:50:28 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r321884 - head/sys/kern
Message-ID:  <201708011750.v71HoSn6055271@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Tue Aug  1 17:50:28 2017
New Revision: 321884
URL: https://svnweb.freebsd.org/changeset/base/321884

Log:
  Fix a witness assertion that fires when a lock type's class changes.
  
  When all instances of a lock type are destroyed (for example, after a
  module unload), the corresponding witness entry remains associated with
  that lock type. In this case, we shouldn't panic if a new instance of the
  lock type is created and its lock class does not match that recorded in the
  witness entry.
  
  Reviewed by:	jhb
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D11788

Modified:
  head/sys/kern/subr_witness.c

Modified: head/sys/kern/subr_witness.c
==============================================================================
--- head/sys/kern/subr_witness.c	Tue Aug  1 16:48:33 2017	(r321883)
+++ head/sys/kern/subr_witness.c	Tue Aug  1 17:50:28 2017	(r321884)
@@ -1850,11 +1850,13 @@ enroll(const char *description, struct lock_class *loc
 found:
 	w->w_refcount++;
 	mtx_unlock_spin(&w_mtx);
-	if (lock_class != w->w_class)
+	if (w->w_refcount == 1)
+		w->w_class = lock_class;
+	else if (lock_class != w->w_class)
 		kassert_panic(
-			"lock (%s) %s does not match earlier (%s) lock",
-			description, lock_class->lc_name,
-			w->w_class->lc_name);
+		    "lock (%s) %s does not match earlier (%s) lock",
+		    description, lock_class->lc_name,
+		    w->w_class->lc_name);
 	return (w);
 }
 



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