Skip to contentSkip to conversation

futex: fix assigned ret variable that is never read

PATCH Applied Colin King 4 participants 5 messages Aug 18, 2021 – Sep 2, 2021 Kernel janitors

lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 futex: fix assigned ret variable that is never read

From: Colin Ian King <[email protected]>

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()")
---
 kernel/futex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/futex.c +1 -1
index e7b4c6121da4..30e7daebaec8 100644
@@ -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))
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Colin,

Às 10:18 de 18/08/21, Colin King escreveu:

Quoted 10 lines

From: Colin Ian King <[email protected]>

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()")
merge bot Applied
#2 lore raw

[tip: locking/urgent] futex: Return error code instead of assigning it without effect

In reply to Colin King
The following commit has been merged into the locking/urgent branch of tip:

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 <[email protected]>
AuthorDate:    Wed, 18 Aug 2021 14:18:40 +01:00
Committer:     Thomas Gleixner <[email protected]>
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")

---
 kernel/futex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/futex.c +1 -1
index e7b4c61..30e7dae 100644
@@ -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))
Acked-by on v1 1/1
#3 lore raw
In reply to Colin King
Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

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.

Quoted 24 lines

Addresses-Coverity: ("Unused value")

Fixes dc7109aaa233 ("futex: Validate waiter correctly in futex_proxy_trylock_atomic()")

---
kernel/futex.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
kernel/futex.c +1 -2
index e7b4c6121da4..30e7daebaec8 100644
@@ -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

merge bot Applied
#4 lore raw

[tip: locking/urgent] futex: Return error code instead of assigning it without effect

In reply to Colin King
The following commit has been merged into the locking/urgent branch of tip:

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 <[email protected]>
AuthorDate:    Wed, 18 Aug 2021 14:18:40 +01:00
Committer:     Thomas Gleixner <[email protected]>
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")

---
 kernel/futex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/futex.c +1 -1
index e7b4c61..30e7dae 100644
@@ -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))