summaryrefslogtreecommitdiff
path: root/net/unix/af_unix.c
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@amazon.com>2024-12-13 14:08:44 +0300
committerPaolo Abeni <pabeni@redhat.com>2024-12-17 14:08:28 +0300
commitf4dd63165b08ba3b72117973d5daea456f36377d (patch)
tree1c759fa81e0a9ed12a17725557029383faa2196c /net/unix/af_unix.c
parent001a25088c35ab69bd4b2f208e47eb8acbce6353 (diff)
downloadlinux-f4dd63165b08ba3b72117973d5daea456f36377d.tar.xz
af_unix: Move !sunaddr case in unix_dgram_sendmsg().
When other is NULL in unix_dgram_sendmsg(), we check if sunaddr is NULL before looking up a receiver socket. There are three paths going through the check, but it's always false for 2 out of the 3 paths: the first socket lookup and the second 'goto restart'. The condition can be true for the first 'goto restart' only when SOCK_DEAD is flagged for the socket found with msg->msg_name. Let's move the check to the single appropriate path. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r--net/unix/af_unix.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 07d6fba99a7c..111f95384990 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2046,11 +2046,6 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
restart:
if (!other) {
- if (!sunaddr) {
- err = -ECONNRESET;
- goto out_free;
- }
-
other = unix_find_other(sock_net(sk), sunaddr, msg->msg_namelen,
sk->sk_type);
if (IS_ERR(other)) {
@@ -2105,6 +2100,9 @@ restart_locked:
err = -ECONNREFUSED;
} else {
unix_state_unlock(sk);
+
+ if (!sunaddr)
+ err = -ECONNRESET;
}
other = NULL;