Skip to content

Commit

Permalink
locking/mutex: Fix debug_mutexes
Browse files Browse the repository at this point in the history
debug_mutex_unlock() would bail when !debug_locks and forgets to
actually unlock.

Reported-by: "Michael L. Semon" <[email protected]>
Reported-by: "Kirill A. Shutemov" <[email protected]>
Reported-by: Valdis Kletnieks <[email protected]>
Fixes: 6f008e7 ("locking/mutex: Fix debug checks")
Tested-by: Dave Jones <[email protected]>
Cc: Jason Low <[email protected]>
Signed-off-by: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Apr 11, 2014
1 parent 467cbd2 commit a227960
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions kernel/locking/mutex-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,17 @@ void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,

void debug_mutex_unlock(struct mutex *lock)
{
if (unlikely(!debug_locks))
return;
if (likely(debug_locks)) {
DEBUG_LOCKS_WARN_ON(lock->magic != lock);

DEBUG_LOCKS_WARN_ON(lock->magic != lock);
if (!lock->owner)
DEBUG_LOCKS_WARN_ON(!lock->owner);
else
DEBUG_LOCKS_WARN_ON(lock->owner != current);

if (!lock->owner)
DEBUG_LOCKS_WARN_ON(!lock->owner);
else
DEBUG_LOCKS_WARN_ON(lock->owner != current);

DEBUG_LOCKS_WARN_ON(!lock->wait_list.prev && !lock->wait_list.next);
mutex_clear_owner(lock);
DEBUG_LOCKS_WARN_ON(!lock->wait_list.prev && !lock->wait_list.next);
mutex_clear_owner(lock);
}

/*
* __mutex_slowpath_needs_to_unlock() is explicitly 0 for debug
Expand Down

0 comments on commit a227960

Please sign in to comment.