Messages in this thread Patch in this message | | | Date | Thu, 19 Aug 2021 20:08:50 +0200 | From | Sebastian Andrzej Siewior <> | Subject | [PATCH] locking/ww_mutex: Initialize waiter.ww_ctx properly |
| |
The gathering of the debug code for the ww-mutex initialized moved the POISON initialiation into one spot and only set waiter.ww_ctx if the ww_ctx was non-NULL thus keeping the POISON value in ww-mutex case.
For ww-mutex without a context it is expected to set the context to NULL, the poison value was intended only for the regular mutex.
Move the waiter.ww_ctx where it was previously so it is initialized to NULL if no ww_ctx was passed.
Fixes: c0afb0ffc06e6 ("locking/ww_mutex: Gather mutex_waiter initialization") Reported-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- kernel/locking/mutex.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c index 05b68931622d1..d1068b0b163af 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -614,8 +614,6 @@ __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclas debug_mutex_lock_common(lock, &waiter); waiter.task = current; - if (ww_ctx) - waiter.ww_ctx = ww_ctx; lock_contended(&lock->dep_map, ip); @@ -630,6 +628,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclas ret = __ww_mutex_add_waiter(&waiter, lock, ww_ctx); if (ret) goto err_early_kill; + waiter.ww_ctx = ww_ctx; } set_current_state(state); -- 2.33.0
| |