locking/lockdep: Fix possible NULL deref

[ Upstream commit 5e351ad106 ]

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: f52be57080 ("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>
This commit is contained in:
Peter Zijlstra 2017-12-06 17:32:47 +01:00 коммит произвёл Greg Kroah-Hartman
Родитель 0aeed5daaf
Коммит a59eb84df2
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -4777,7 +4777,8 @@ void lockdep_invariant_state(bool force)
* Verify the former, enforce the latter. * Verify the former, enforce the latter.
*/ */
WARN_ON_ONCE(!force && current->lockdep_depth); 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) static int cross_lock(struct lockdep_map *lock)