locking/ww_mutex: Fix acquire/release imbalance in ww_acquire_init()/ww_acquire_fini()
authorWaiman Long <longman@redhat.com>
Tue, 16 Mar 2021 15:31:17 +0000 (11:31 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 7 Apr 2021 13:00:06 +0000 (15:00 +0200)
commit3ac4aaff387bf9a2be6de0a8a1adb173d822ac6a
tree24e087a26762b3ce01b25cd8a27cd63168e02a88
parent905ef030bdf9710ae7581ecf13be07cae59c815f
locking/ww_mutex: Fix acquire/release imbalance in ww_acquire_init()/ww_acquire_fini()

[ Upstream commit bee645788e07eea63055d261d2884ea45c2ba857 ]

In ww_acquire_init(), mutex_acquire() is gated by CONFIG_DEBUG_LOCK_ALLOC.
The dep_map in the ww_acquire_ctx structure is also gated by the
same config. However mutex_release() in ww_acquire_fini() is gated by
CONFIG_DEBUG_MUTEXES. It is possible to set CONFIG_DEBUG_MUTEXES without
setting CONFIG_DEBUG_LOCK_ALLOC though it is an unlikely configuration.
That may cause a compilation error as dep_map isn't defined in this
case. Fix this potential problem by enclosing mutex_release() inside
CONFIG_DEBUG_LOCK_ALLOC.

Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210316153119.13802-3-longman@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/ww_mutex.h