From: Peter Zijlstra Date: Wed, 6 Dec 2017 16:32:47 +0000 (+0100) Subject: locking/lockdep: Fix possible NULL deref X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5e351ad106997e06b2dc3da9c6b939b95f67fb88;p=linux.git locking/lockdep: Fix possible NULL deref We can't invalidate xhlocks when we've not yet allocated any. Reported-by: Dmitry Vyukov Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Fixes: f52be5708076 ("locking/lockdep: Untangle xhlock history save/restore from task independence") Signed-off-by: Ingo Molnar --- diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 9776da8db180d..670d8d7d8087c 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -4790,7 +4790,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)