# HG changeset patch # User Josef 'Jeff' Sipek # Date 1564072347 14400 # Node ID de53a9548b85539ca35750532bdf146cda359adc # Parent ac902673ea0a927a682cf7db7a82b8ca897bb4dc synch: check synch type of locks Signed-off-by: Josef 'Jeff' Sipek diff -r ac902673ea0a -r de53a9548b85 synch.c --- a/synch.c Thu Jul 25 12:32:05 2019 -0400 +++ b/synch.c Thu Jul 25 12:32:27 2019 -0400 @@ -393,12 +393,9 @@ /* * state checking */ -static void check_lock_magic(struct lock *lock, const char *op, - const struct lock_context *where) +static void __bad_magic(struct lock *lock, const char *op, + const struct lock_context *where) { - if (lock->info.magic == (uintptr_t) &lock->info) - return; - cmn_err(CE_CRIT, "lockdep: thread trying to %s lock with bad magic", op); print_lock(lock, where); #ifdef JEFFPC_LOCK_TRACKING @@ -408,6 +405,28 @@ panic("lockdep: Aborting - bad lock magic"); } +static void __bad_type(struct lock *lock, const char *op, + const struct lock_context *where) +{ + cmn_err(CE_CRIT, "lockdep: thread trying to %s lock with " + "mismatched synch type", op); + print_lock(lock, where); +#ifdef JEFFPC_LOCK_TRACKING + cmn_err(CE_CRIT, "lockdep: while holding:"); + print_held_locks(NULL); +#endif + panic("lockdep: Aborting - mismatched synch type"); +} + +static void check_lock_magic(struct lock *lock, const char *op, + const struct lock_context *where) +{ + if (lock->info.magic != (uintptr_t) &lock->info) + __bad_magic(lock, op, where); + else if (lock->info.type != SYNCH_TYPE_MUTEX) + __bad_type(lock, op, where); +} + static void check_rw_magic(struct rwlock *lock, const char *op, const struct lock_context *where) {