LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH][next] futex: fix assigned ret variable that is never read
@ 2021-08-18 13:18 Colin King
2021-09-01 18:26 ` André Almeida
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Colin King @ 2021-08-18 13:18 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Peter Zijlstra, Darren Hart,
Davidlohr Bueso
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently the check on the rt_waiter and top_waiter->pi_state is
assigning an error return code to ret but this later gets re-assigned,
hence the check is currently ineffective. I believe the original
intent was to return -EINVAL rather than assign it to ret. Fix this.
Addresses-Coverity: ("Unused value")
Fixes: dc7109aaa233 ("futex: Validate waiter correctly in futex_proxy_trylock_atomic()")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
kernel/futex.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/futex.c b/kernel/futex.c
index e7b4c6121da4..30e7daebaec8 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2025,7 +2025,7 @@ futex_proxy_trylock_atomic(u32 __user *pifutex, struct futex_hash_bucket *hb1,
* and waiting on the 'waitqueue' futex which is always !PI.
*/
if (!top_waiter->rt_waiter || top_waiter->pi_state)
- ret = -EINVAL;
+ return -EINVAL;
/* Ensure we requeue to the expected futex. */
if (!match_futex(top_waiter->requeue_pi_key, key2))
--
2.32.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][next] futex: fix assigned ret variable that is never read
2021-08-18 13:18 [PATCH][next] futex: fix assigned ret variable that is never read Colin King
@ 2021-09-01 18:26 ` André Almeida
2021-09-01 19:28 ` [tip: locking/urgent] futex: Return error code instead of assigning it without effect tip-bot2 for Colin Ian King
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: André Almeida @ 2021-09-01 18:26 UTC (permalink / raw)
To: Colin King
Cc: kernel-janitors, Ingo Molnar, linux-kernel, Thomas Gleixner,
Davidlohr Bueso, Darren Hart, Peter Zijlstra
Hi Colin,
Às 10:18 de 18/08/21, Colin King escreveu:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the check on the rt_waiter and top_waiter->pi_state is
> assigning an error return code to ret but this later gets re-assigned,
> hence the check is currently ineffective. I believe the original
> intent was to return -EINVAL rather than assign it to ret. Fix this.
>
> Addresses-Coverity: ("Unused value")
> Fixes: dc7109aaa233 ("futex: Validate waiter correctly in futex_proxy_trylock_atomic()")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>> ---
Reviewed-by: André Almeida <andrealmeid@collabora.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip: locking/urgent] futex: Return error code instead of assigning it without effect
2021-08-18 13:18 [PATCH][next] futex: fix assigned ret variable that is never read Colin King
2021-09-01 18:26 ` André Almeida
@ 2021-09-01 19:28 ` tip-bot2 for Colin Ian King
2021-09-01 20:24 ` [PATCH][next] futex: fix assigned ret variable that is never read Davidlohr Bueso
2021-09-02 20:14 ` [tip: locking/urgent] futex: Return error code instead of assigning it without effect tip-bot2 for Colin Ian King
3 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Colin Ian King @ 2021-09-01 19:28 UTC (permalink / raw)
To: linux-tip-commits
Cc: Colin Ian King, Thomas Gleixner, andrealmeid, x86, linux-kernel
The following commit has been merged into the locking/urgent branch of tip:
Commit-ID: 1f15eb89144fdd4c881ef7181d51e989a732f4f0
Gitweb: https://git.kernel.org/tip/1f15eb89144fdd4c881ef7181d51e989a732f4f0
Author: Colin Ian King <colin.king@canonical.com>
AuthorDate: Wed, 18 Aug 2021 14:18:40 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 01 Sep 2021 21:26:33 +02:00
futex: Return error code instead of assigning it without effect
The check on the rt_waiter and top_waiter->pi_state is assigning an error
return code to ret but this later gets re-assigned, hence the check is
ineffective.
Return -EINVAL rather than assigning it to ret which was the original
intent.
Fixes: dc7109aaa233 ("futex: Validate waiter correctly in futex_proxy_trylock_atomic()")
Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: André Almeida <andrealmeid@collabora.com>
Link: https://lore.kernel.org/r/20210818131840.34262-1-colin.king@canonical.com
---
kernel/futex.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/futex.c b/kernel/futex.c
index e7b4c61..30e7dae 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2025,7 +2025,7 @@ futex_proxy_trylock_atomic(u32 __user *pifutex, struct futex_hash_bucket *hb1,
* and waiting on the 'waitqueue' futex which is always !PI.
*/
if (!top_waiter->rt_waiter || top_waiter->pi_state)
- ret = -EINVAL;
+ return -EINVAL;
/* Ensure we requeue to the expected futex. */
if (!match_futex(top_waiter->requeue_pi_key, key2))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][next] futex: fix assigned ret variable that is never read
2021-08-18 13:18 [PATCH][next] futex: fix assigned ret variable that is never read Colin King
2021-09-01 18:26 ` André Almeida
2021-09-01 19:28 ` [tip: locking/urgent] futex: Return error code instead of assigning it without effect tip-bot2 for Colin Ian King
@ 2021-09-01 20:24 ` Davidlohr Bueso
2021-09-02 20:14 ` [tip: locking/urgent] futex: Return error code instead of assigning it without effect tip-bot2 for Colin Ian King
3 siblings, 0 replies; 5+ messages in thread
From: Davidlohr Bueso @ 2021-09-01 20:24 UTC (permalink / raw)
To: Colin King
Cc: Thomas Gleixner, Ingo Molnar, Peter Zijlstra, Darren Hart,
kernel-janitors, linux-kernel
On Wed, 18 Aug 2021, Colin King wrote:
>From: Colin Ian King <colin.king@canonical.com>
>
>Currently the check on the rt_waiter and top_waiter->pi_state is
>assigning an error return code to ret but this later gets re-assigned,
>hence the check is currently ineffective. I believe the original
>intent was to return -EINVAL rather than assign it to ret. Fix this.
LGTM.
Acked-by: Davidlohr Bueso <dbueso@suse.de>
>
>Addresses-Coverity: ("Unused value")
>Fixes: dc7109aaa233 ("futex: Validate waiter correctly in futex_proxy_trylock_atomic()")
>Signed-off-by: Colin Ian King <colin.king@canonical.com>
>---
> kernel/futex.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/kernel/futex.c b/kernel/futex.c
>index e7b4c6121da4..30e7daebaec8 100644
>--- a/kernel/futex.c
>+++ b/kernel/futex.c
>@@ -2025,7 +2025,7 @@ futex_proxy_trylock_atomic(u32 __user *pifutex, struct futex_hash_bucket *hb1,
> * and waiting on the 'waitqueue' futex which is always !PI.
> */
> if (!top_waiter->rt_waiter || top_waiter->pi_state)
>- ret = -EINVAL;
>+ return -EINVAL;
>
> /* Ensure we requeue to the expected futex. */
> if (!match_futex(top_waiter->requeue_pi_key, key2))
>--
>2.32.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip: locking/urgent] futex: Return error code instead of assigning it without effect
2021-08-18 13:18 [PATCH][next] futex: fix assigned ret variable that is never read Colin King
` (2 preceding siblings ...)
2021-09-01 20:24 ` [PATCH][next] futex: fix assigned ret variable that is never read Davidlohr Bueso
@ 2021-09-02 20:14 ` tip-bot2 for Colin Ian King
3 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Colin Ian King @ 2021-09-02 20:14 UTC (permalink / raw)
To: linux-tip-commits
Cc: Colin Ian King, Thomas Gleixner, andrealmeid, x86, linux-kernel
The following commit has been merged into the locking/urgent branch of tip:
Commit-ID: a974b54036f79dd5e395e9f6c80c3decb4661a14
Gitweb: https://git.kernel.org/tip/a974b54036f79dd5e395e9f6c80c3decb4661a14
Author: Colin Ian King <colin.king@canonical.com>
AuthorDate: Wed, 18 Aug 2021 14:18:40 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 02 Sep 2021 22:07:18 +02:00
futex: Return error code instead of assigning it without effect
The check on the rt_waiter and top_waiter->pi_state is assigning an error
return code to ret but this later gets re-assigned, hence the check is
ineffective.
Return -EINVAL rather than assigning it to ret which was the original
intent.
Fixes: dc7109aaa233 ("futex: Validate waiter correctly in futex_proxy_trylock_atomic()")
Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: André Almeida <andrealmeid@collabora.com>
Link: https://lore.kernel.org/r/20210818131840.34262-1-colin.king@canonical.com
---
kernel/futex.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/futex.c b/kernel/futex.c
index e7b4c61..30e7dae 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2025,7 +2025,7 @@ futex_proxy_trylock_atomic(u32 __user *pifutex, struct futex_hash_bucket *hb1,
* and waiting on the 'waitqueue' futex which is always !PI.
*/
if (!top_waiter->rt_waiter || top_waiter->pi_state)
- ret = -EINVAL;
+ return -EINVAL;
/* Ensure we requeue to the expected futex. */
if (!match_futex(top_waiter->requeue_pi_key, key2))
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-09-02 20:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18 13:18 [PATCH][next] futex: fix assigned ret variable that is never read Colin King
2021-09-01 18:26 ` André Almeida
2021-09-01 19:28 ` [tip: locking/urgent] futex: Return error code instead of assigning it without effect tip-bot2 for Colin Ian King
2021-09-01 20:24 ` [PATCH][next] futex: fix assigned ret variable that is never read Davidlohr Bueso
2021-09-02 20:14 ` [tip: locking/urgent] futex: Return error code instead of assigning it without effect tip-bot2 for Colin Ian King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).