]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
af_unix: Set error only when needed in unix_stream_sendmsg().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Fri, 13 Dec 2024 11:08:41 +0000 (20:08 +0900)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 17 Dec 2024 11:08:27 +0000 (12:08 +0100)
We will introduce skb drop reason for AF_UNIX, then we need to
set an errno and a drop reason for each path.

Let's set an error only when it's needed in unix_stream_sendmsg().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/unix/af_unix.c

index 21e17e739f88acaef674c92edfe6119c77d9941b..660d8b8130cab691afcae6083d3bdf9833f119b7 100644 (file)
@@ -2254,8 +2254,8 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
 
        wait_for_unix_gc(scm.fp);
 
-       err = -EOPNOTSUPP;
        if (msg->msg_flags & MSG_OOB) {
+               err = -EOPNOTSUPP;
 #if IS_ENABLED(CONFIG_AF_UNIX_OOB)
                if (len)
                        len--;
@@ -2268,10 +2268,11 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
                err = READ_ONCE(sk->sk_state) == TCP_ESTABLISHED ? -EISCONN : -EOPNOTSUPP;
                goto out_err;
        } else {
-               err = -ENOTCONN;
                other = unix_peer(sk);
-               if (!other)
+               if (!other) {
+                       err = -ENOTCONN;
                        goto out_err;
+               }
        }
 
        if (READ_ONCE(sk->sk_shutdown) & SEND_SHUTDOWN)