[PATCH] net: unix: Fix undefined 'other' error
From: Purva Yeshi
Date: Sun Feb 09 2025 - 13:44:34 EST
Fix issue detected by smatch tool:
An "undefined 'other'" error occur in __releases() annotation.
The issue occurs because __releases(&unix_sk(other)->lock) is placed
at the function signature level, where other is not yet in scope.
Fix this by replacing it with __releases(&u->lock), using u, a local
variable, which is properly defined inside the function.
Signed-off-by: Purva Yeshi <purvayeshi550@xxxxxxxxx>
---
net/unix/af_unix.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 34945de1f..37b01605a 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1508,7 +1508,10 @@ 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)
+ /*
+ * Use local variable instead of function parameter
+ */
+ __releases(&u->lock)
{
struct unix_sock *u = unix_sk(other);
int sched;
--
2.34.1