Skip to content

Commit

Permalink
af_unix: Defer sock_put() to clean up path in unix_dgram_sendmsg().
Browse files Browse the repository at this point in the history
When other has SOCK_DEAD in unix_dgram_sendmsg(), we call sock_put() for
it first and then set NULL to other before jumping to the error path.

This is to skip sock_put() in the error path.

Let's not set NULL to other and defer the sock_put() to the error path
to clean up the labels later.

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 a700b43 commit 689c398
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions net/unix/af_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,6 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
* datagram error
*/
unix_state_unlock(other);
sock_put(other);

if (!sk_locked)
unix_state_lock(sk);
Expand Down Expand Up @@ -2104,7 +2103,6 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
err = -ECONNRESET;
}

other = NULL;
if (err)
goto out_free;

Expand Down

0 comments on commit 689c398

Please sign in to comment.