[PATCH 3.12 139/142] futex: Drop refcount if requeue_pi() acquired the rtmutex

From: Jiri Slaby
Date: Wed Feb 24 2016 - 05:09:11 EST


From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>

3.12-stable review patch. If anyone has any objections, please let me know.

===============

commit fb75a4282d0d9a3c7c44d940582c2d226cf3acfb upstream.

If the proxy lock in the requeue loop acquires the rtmutex for a
waiter then it acquired also refcount on the pi_state related to the
futex, but the waiter side does not drop the reference count.

Add the missing free_pi_state() call.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Darren Hart <darren@xxxxxxxxxx>
Cc: Davidlohr Bueso <dave@xxxxxxxxxxxx>
Cc: Bhuvanesh_Surachari@xxxxxxxxxx
Cc: Andy Lowe <Andy_Lowe@xxxxxxxxxx>
Link: http://lkml.kernel.org/r/20151219200607.178132067@xxxxxxxxxxxxx
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
---
kernel/futex.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/kernel/futex.c b/kernel/futex.c
index 3ee1b3ce78df..509bdd404414 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2497,6 +2497,11 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
if (q.pi_state && (q.pi_state->owner != current)) {
spin_lock(q.lock_ptr);
ret = fixup_pi_state_owner(uaddr2, &q, current);
+ /*
+ * Drop the reference to the pi state which
+ * the requeue_pi() code acquired for us.
+ */
+ free_pi_state(q.pi_state);
spin_unlock(q.lock_ptr);
}
} else {
--
2.7.1