Skip to contentSkip to conversation

af_unix: Fix undefined 'other' error

PATCH Applied Purva Yeshi 3 participants 3 messages Feb 18, 2025 – Feb 21, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 af_unix: Fix undefined 'other' error

Fix an issue detected by the Smatch static analysis tool where an "undefined 'other'" error occurs due to __releases(&unix_sk(other)->lock) being placed before 'other' is in scope.

Remove the __releases() annotation from the unix_wait_for_peer() function to eliminate the Smatch warning. The annotation references other before it is declared, leading to a false positive error during static analysis.

Since AF_UNIX does not use Sparse annotations, this annotation is unnecessary and does not impact functionality.

---
V1 - https://lore.kernel.org/lkml/[email protected]/
V2 - https://lore.kernel.org/all/[email protected]/
V3 - Remove trailing double spaces.

 net/unix/af_unix.c | 1 -
 1 file changed, 1 deletion(-)
net/unix/af_unix.c +0 -1
index 34945de1f..319153850 100644
@@ -1508,7 +1508,6 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
 }
 
 static long unix_wait_for_peer(struct sock *other, long timeo)
-	__releases(&unix_sk(other)->lock)
 {
 	struct unix_sock *u = unix_sk(other);
 	int sched;
Signature · 1 line
2.34.1
Reviewed-by on v3 1/1
#1 lore raw

From: Purva Yeshi <[email protected]>
Date: Tue, 18 Feb 2025 19:40:45 +0530

Quoted 3 lines

Fix an issue detected by the Smatch static analysis tool where an "undefined 'other'" error occurs due to __releases(&unix_sk(other)->lock) being placed before 'other' is in scope.

I don't care much, but according to Dan, this is Sparse error due to const unix_sk() ?

https://lore.kernel.org/all/[email protected]/

Quoted 3 lines

Remove the __releases() annotation from the unix_wait_for_peer() function to eliminate the Smatch warning. The annotation references other

Same here ?

Quoted 7 lines

before it is declared, leading to a false positive error during static analysis.

Since AF_UNIX does not use Sparse annotations, this annotation is unnecessary and does not impact functionality.

Anyway,

Also, I think you can carry over Joe and Simon's tags as the change is trivial.

#2 lore raw
In reply to Purva Yeshi
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Tue, 18 Feb 2025 19:40:45 +0530 you wrote:

Fix an issue detected by the Smatch static analysis tool where an "undefined 'other'" error occurs due to __releases(&unix_sk(other)->lock) being placed before 'other' is in scope.

Remove the __releases() annotation from the unix_wait_for_peer() function to eliminate the Smatch warning. The annotation references other before it is declared, leading to a false positive error during static analysis.

[...]

Here is the summary with links:
- [net-next,v3] af_unix: Fix undefined 'other' error

    https://git.kernel.org/netdev/net-next/c/1340461e5168

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html