summaryrefslogtreecommitdiffstats
path: root/kernel/locking
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2017-12-06 17:32:47 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-02-25 11:08:00 +0100
commita59eb84df2b793856fd3ba2eaca4098e95231058 (patch)
treeb8ce6efc42c62110a2afe97ed071cd12aaa9b8c4 /kernel/locking
parent0aeed5daaf62a38261f1198e4491c0ebf59528d9 (diff)
downloadlinux-stable-a59eb84df2b793856fd3ba2eaca4098e95231058.tar.gz
linux-stable-a59eb84df2b793856fd3ba2eaca4098e95231058.tar.bz2
linux-stable-a59eb84df2b793856fd3ba2eaca4098e95231058.zip
locking/lockdep: Fix possible NULL deref
[ Upstream commit 5e351ad106997e06b2dc3da9c6b939b95f67fb88 ] We can't invalidate xhlocks when we've not yet allocated any. Reported-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Fixes: f52be5708076 ("locking/lockdep: Untangle xhlock history save/restore from task independence") Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel/locking')
-rw-r--r--kernel/locking/lockdep.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 4d362d3e4571..2f0f5720b123 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -4777,7 +4777,8 @@ void lockdep_invariant_state(bool force)
* Verify the former, enforce the latter.
*/
WARN_ON_ONCE(!force && current->lockdep_depth);
- invalidate_xhlock(&xhlock(current->xhlock_idx));
+ if (current->xhlocks)
+ invalidate_xhlock(&xhlock(current->xhlock_idx));
}
static int cross_lock(struct lockdep_map *lock)