Amend r321884 to check the refcount and update the class with w_mtx held.

Reviewed by:	jhb
X-MFC with:	r321884
This commit is contained in:
Mark Johnston 2017-08-01 23:14:38 +00:00
parent fad5dbf8d5
commit 526b5fe16c

View File

@ -1849,10 +1849,10 @@ enroll(const char *description, struct lock_class *lock_class)
return (w);
found:
w->w_refcount++;
mtx_unlock_spin(&w_mtx);
if (w->w_refcount == 1)
w->w_class = lock_class;
else if (lock_class != w->w_class)
mtx_unlock_spin(&w_mtx);
if (lock_class != w->w_class)
kassert_panic(
"lock (%s) %s does not match earlier (%s) lock",
description, lock_class->lc_name,