]> Git Repo - linux.git/commitdiff
locking/rtmutex: Fix ww_mutex deadlock check
authorPeter Zijlstra <[email protected]>
Wed, 1 Sep 2021 09:44:11 +0000 (11:44 +0200)
committerThomas Gleixner <[email protected]>
Thu, 9 Sep 2021 08:31:22 +0000 (10:31 +0200)
Dan reported that rt_mutex_adjust_prio_chain() can be called with
.orig_waiter == NULL however commit a055fcc132d4 ("locking/rtmutex: Return
success on deadlock for ww_mutex waiters") unconditionally dereferences it.

Since both call-sites that have .orig_waiter == NULL don't care for the
return value, simply disable the deadlock squash by adding the NULL check.

Notably, both callers use the deadlock condition as a termination condition
for the iteration; once detected, it is sure that (de)boosting is done.
Arguably step [3] would be a more natural termination point, but it's
dubious whether adding a third deadlock detection state would improve the
code.

Fixes: a055fcc132d4 ("locking/rtmutex: Return success on deadlock for ww_mutex waiters")
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Acked-by: Sebastian Andrzej Siewior <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
kernel/locking/rtmutex.c

index 8eabdc79602b8b50e5344b0288fef2b190fde5da..6bb116c559b4a0a1d4052c7feccc88d21eefb556 100644 (file)
@@ -753,7 +753,7 @@ static int __sched rt_mutex_adjust_prio_chain(struct task_struct *task,
                 * other configuration and we fail to report; also, see
                 * lockdep.
                 */
-               if (IS_ENABLED(CONFIG_PREEMPT_RT) && orig_waiter->ww_ctx)
+               if (IS_ENABLED(CONFIG_PREEMPT_RT) && orig_waiter && orig_waiter->ww_ctx)
                        ret = 0;
 
                raw_spin_unlock(&lock->wait_lock);
This page took 0.059135 seconds and 4 git commands to generate.