Skip to content

Commit bee6457

Browse files
Waiman-LongIngo Molnar
authored andcommitted
locking/ww_mutex: Fix acquire/release imbalance in ww_acquire_init()/ww_acquire_fini()
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 <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5de2055 commit bee6457

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

include/linux/ww_mutex.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,10 @@ static inline void ww_acquire_done(struct ww_acquire_ctx *ctx)
173173
*/
174174
static inline void ww_acquire_fini(struct ww_acquire_ctx *ctx)
175175
{
176-
#ifdef CONFIG_DEBUG_MUTEXES
176+
#ifdef CONFIG_DEBUG_LOCK_ALLOC
177177
mutex_release(&ctx->dep_map, _THIS_IP_);
178-
178+
#endif
179+
#ifdef CONFIG_DEBUG_MUTEXES
179180
DEBUG_LOCKS_WARN_ON(ctx->acquired);
180181
if (!IS_ENABLED(CONFIG_PROVE_LOCKING))
181182
/*

0 commit comments

Comments
 (0)