The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <purvayeshi550@gmail.com>
Cc: <davem@davemloft.net>, <edumazet@google.com>, <horms@kernel.org>,
	<kuba@kernel.org>, <linux-kernel@vger.kernel.org>,
	<netdev@vger.kernel.org>, <pabeni@redhat.com>,
	<skhan@linuxfoundation.org>
Subject: Re: [PATCH] net: unix: Fix undefined 'other' error
Date: Mon, 10 Feb 2025 09:26:32 +0900	[thread overview]
Message-ID: <20250210002632.48499-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20250209184355.16257-1-purvayeshi550@gmail.com>


> [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

  reply	other threads:[~2025-02-10  0:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-09 18:43 [PATCH] net: unix: Fix undefined 'other' error Purva Yeshi
2025-02-10  0:26 ` Kuniyuki Iwashima [this message]
2025-02-10  7:45   ` Purva Yeshi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250210002632.48499-1-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=purvayeshi550@gmail.com \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox