diff mbox series

[net-next,v3] af_unix: Fix undefined 'other' error

Message ID 20250218141045.38947-1-purvayeshi550@gmail.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v3] af_unix: Fix undefined 'other' error | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: kuniyu@amazon.com
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 4 this patch: 11
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Purva Yeshi Feb. 18, 2025, 2:10 p.m. UTC
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.

Signed-off-by: Purva Yeshi <purvayeshi550@gmail.com>
---
V1 - https://lore.kernel.org/lkml/20250209184355.16257-1-purvayeshi550@gmail.com/
V2 - https://lore.kernel.org/all/20250212104845.2396abcf@kernel.org/
V3 - Remove trailing double spaces.

 net/unix/af_unix.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Kuniyuki Iwashima Feb. 18, 2025, 6:39 p.m. UTC | #1
From: Purva Yeshi <purvayeshi550@gmail.com>
Date: Tue, 18 Feb 2025 19:40:45 +0530
> 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/bbf51850-814a-4a30-8165-625d88f221a5@stanley.mountain/

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

Same here ?


> 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.
> 
> Signed-off-by: Purva Yeshi <purvayeshi550@gmail.com>

Anyway,

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>

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

Patch

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 34945de1f..319153850 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -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;