Skip to contentSkip to conversation

futex: Fix locking imbalance

tip:core/urgent tip-bot for Thomas Gleixner 1 participant 1 message Oct 5, 2009

lore
Share & tools
lore
#0 lore raw
Commit-ID:  eaaea8036d0261d87d7072c5bc88c7ea730c18ac
Gitweb:     http://git.kernel.org/tip/eaaea8036d0261d87d7072c5bc88c7ea730c18ac
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Sun, 4 Oct 2009 09:34:17 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 5 Oct 2009 21:08:14 +0200

futex: Fix locking imbalance

Rich reported a lock imbalance in the futex code:

http://bugzilla.kernel.org/show_bug.cgi?id=14288

It's caused by the displacement of the retry_private label in futex_wake_op(). The code unlocks the hash bucket locks in the error handling path and retries without locking them again which makes the next unlock fail.

Move retry_private so we lock the hash bucket locks when we retry.

LKML-Reference: <new-submission>

---
 kernel/futex.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/futex.c +1 -1
index 463af2e..1e176f3 100644
@@ -916,8 +916,8 @@ retry:
 	hb1 = hash_futex(&key1);
 	hb2 = hash_futex(&key2);
 
-	double_lock_hb(hb1, hb2);
 retry_private:
+	double_lock_hb(hb1, hb2);
 	op_ret = futex_atomic_op_inuser(op, uaddr2);
 	if (unlikely(op_ret < 0)) {