[patch V3 56/64] futex: Correct the number of requeued waiters for PI
From: Thomas Gleixner
Date: Thu Aug 05 2021 - 11:45:52 EST
From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
The accounting is wrong when either the PI sanity check or the
requeue PI operation fails. Adjust it in the failure path.
Will be simplified in the next step.
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
kernel/futex.c | 4 ++++
1 file changed, 4 insertions(+)
---
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2131,6 +2131,8 @@ static int futex_requeue(u32 __user *uad
/* Ensure we requeue to the expected futex for requeue_pi. */
if (requeue_pi && !match_futex(this->requeue_pi_key, &key2)) {
+ /* Don't account for it */
+ task_count--;
ret = -EINVAL;
break;
}
@@ -2172,6 +2174,8 @@ static int futex_requeue(u32 __user *uad
*/
this->pi_state = NULL;
put_pi_state(pi_state);
+ /* Don't account for it */
+ task_count--;
/*
* We stop queueing more waiters and let user
* space deal with the mess.