Skip to content

Commit

Permalink
af_unix: Set error only when needed in unix_stream_sendmsg().
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kuniyuki Iwashima authored and Paolo Abeni committed Dec 17, 2024
1 parent e26ee0a commit 6c44425
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions net/unix/af_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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--;
Expand All @@ -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)
Expand Down

0 comments on commit 6c44425

Please sign in to comment.