Commit-ID:  9bbb25afeb182502ca4f2c4f3f88af0681b34cae
Gitweb:     http://git.kernel.org/tip/9bbb25afeb182502ca4f2c4f3f88af0681b34cae
Author:     Peter Zijlstra <pet...@infradead.org>
AuthorDate: Sat, 4 Mar 2017 10:27:19 +0100
Committer:  Thomas Gleixner <t...@linutronix.de>
CommitDate: Tue, 14 Mar 2017 21:45:36 +0100

futex: Add missing error handling to FUTEX_REQUEUE_PI

Thomas spotted that fixup_pi_state_owner() can return errors and we
fail to unlock the rt_mutex in that case.

Reported-by: Thomas Gleixner <t...@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <pet...@infradead.org>
Reviewed-by: Darren Hart <dvh...@linux.intel.com>
Cc: juri.le...@arm.com
Cc: bige...@linutronix.de
Cc: xlp...@redhat.com
Cc: rost...@goodmis.org
Cc: mathieu.desnoy...@efficios.com
Cc: jdesfos...@efficios.com
Cc: dvh...@infradead.org
Cc: bris...@redhat.com
Cc: sta...@vger.kernel.org
Link: http://lkml.kernel.org/r/20170304093558.867401...@infradead.org
Signed-off-by: Thomas Gleixner <t...@linutronix.de>

---
 kernel/futex.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/futex.c b/kernel/futex.c
index 3a4775f..45858ec 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2898,6 +2898,8 @@ 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);
+                       if (ret && rt_mutex_owner(&q.pi_state->pi_mutex) == 
current)
+                               rt_mutex_unlock(&q.pi_state->pi_mutex);
                        /*
                         * Drop the reference to the pi state which
                         * the requeue_pi() code acquired for us.

Reply via email to