netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: unix: Fix undefined 'other' error
@ 2025-02-09 18:43 Purva Yeshi
  2025-02-10  0:26 ` Kuniyuki Iwashima
  0 siblings, 1 reply; 3+ messages in thread
From: Purva Yeshi @ 2025-02-09 18:43 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni
  Cc: skhan, horms, netdev, linux-kernel, purvayeshi550

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: unix: Fix undefined 'other' error
  2025-02-09 18:43 [PATCH] net: unix: Fix undefined 'other' error Purva Yeshi
@ 2025-02-10  0:26 ` Kuniyuki Iwashima
  2025-02-10  7:45   ` Purva Yeshi
  0 siblings, 1 reply; 3+ messages in thread
From: Kuniyuki Iwashima @ 2025-02-10  0:26 UTC (permalink / raw)
  To: purvayeshi550
  Cc: davem, edumazet, horms, kuba, linux-kernel, netdev, pabeni, skhan


> [PATCH] net: unix: Fix undefined 'other' error

Please add net-next after PATCH and start with af_unix: as with
other commits when you post v2.

[PATCH net-next v2]: af_unix: ...


From: Purva Yeshi <purvayeshi550@gmail.com>
Date: Mon, 10 Feb 2025 00:13:55 +0530
> 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.

Tweaking an annotation with a comment for a static analyzer to fix
a warning for yet another static analyzer is too much.

Please remove sparse annotation instead.

Here's the only place where sparse is used in AF_UNIX code, and we
don't use sparse even for /proc/net/unix.


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: unix: Fix undefined 'other' error
  2025-02-10  0:26 ` Kuniyuki Iwashima
@ 2025-02-10  7:45   ` Purva Yeshi
  0 siblings, 0 replies; 3+ messages in thread
From: Purva Yeshi @ 2025-02-10  7:45 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: davem, edumazet, horms, kuba, linux-kernel, netdev, pabeni, skhan

On 10/02/25 05:56, Kuniyuki Iwashima wrote:
> 
>> [PATCH] net: unix: Fix undefined 'other' error
> 
> Please add net-next after PATCH and start with af_unix: as with
> other commits when you post v2.
> 
> [PATCH net-next v2]: af_unix: ...
> 
> 
> From: Purva Yeshi <purvayeshi550@gmail.com>
> Date: Mon, 10 Feb 2025 00:13:55 +0530
>> 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.
> 
> Tweaking an annotation with a comment for a static analyzer to fix
> a warning for yet another static analyzer is too much.
> 
> Please remove sparse annotation instead.
> 
> Here's the only place where sparse is used in AF_UNIX code, and we
> don't use sparse even for /proc/net/unix.

Thank you for the feedback. As per your suggestion, I have removed the 
Sparse annotation instead of modifying it. I have updated the patch 
accordingly and will send v2 with the corrected subject line and commit 
message.

Best regards,
Purva Yeshi

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-10  7:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-09 18:43 [PATCH] net: unix: Fix undefined 'other' error Purva Yeshi
2025-02-10  0:26 ` Kuniyuki Iwashima
2025-02-10  7:45   ` Purva Yeshi

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).