Skip to content

Commit

Permalink
rt-mutex: fix stale return value
Browse files Browse the repository at this point in the history
Alexey Kuznetsov found some problems in the pi-futex code.

The major problem is a stale return value in rt_mutex_slowlock():

When the pi chain walk returns -EDEADLK, but the waiter was woken up during
the phases where the locks were dropped, the rtmutex could be acquired, but
due to the stale return value -EDEADLK returned to the caller.

Reset the return value in the retry path.

Signed-off-by: Thomas Gleixner <[email protected]>
Acked-by: Ingo Molnar <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Alexey Kuznetsov <[email protected]>
Cc: Ulrich Drepper <[email protected]>
Cc: Eric Dumazet <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
KAGA-KOKO authored and Linus Torvalds committed Jun 9, 2007
1 parent 51b94d2 commit c0d1d2b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions kernel/rtmutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,16 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
* all over without going into schedule to try
* to get the lock now:
*/
if (unlikely(!waiter.task))
if (unlikely(!waiter.task)) {
/*
* Reset the return value. We might
* have returned with -EDEADLK and the
* owner released the lock while we
* were walking the pi chain.
*/
ret = 0;
continue;

}
if (unlikely(ret))
break;
}
Expand Down

0 comments on commit c0d1d2b

Please sign in to comment.