[PATCH] locking/ww_mutex: set ret variable on failure

From: trix
Date: Mon Sep 27 2021 - 10:58:07 EST


From: Tom Rix <trix@xxxxxxxxxx>

Building with clang 13 produces this error
test-ww_mutex.c:138:7: error: variable 'ret' is used
uninitialized whenever 'if' condition is true
[-Werror,-Wsometimes-uninitialized]
if (!ww_mutex_trylock(&mutex, &ctx)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

On this failure set ret to -EINVAL as is similarly done
in the function.

Signed-off-by: Tom Rix <trix@xxxxxxxxxx>
---
kernel/locking/test-ww_mutex.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index d63ac411f36722..7dbac5dc02efb7 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -137,6 +137,7 @@ static int test_aa(bool trylock)
} else {
if (!ww_mutex_trylock(&mutex, &ctx)) {
pr_err("%s: initial trylock failed!\n", __func__);
+ ret = -EINVAL;
goto out;
}
}
--
2.26.3