]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
af_unix: Defer sock_put() to clean up path in unix_dgram_sendmsg().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Fri, 13 Dec 2024 11:08:47 +0000 (20:08 +0900)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 17 Dec 2024 11:08:28 +0000 (12:08 +0100)
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>
net/unix/af_unix.c

index 513d0fd12e6a974bae720b0985e511a9aeff2ae3..b8adfb41d11bcdfdb39cbe4979170a02960ff8e3 100644 (file)
@@ -2075,7 +2075,6 @@ restart_locked:
                 *      datagram error
                 */
                unix_state_unlock(other);
-               sock_put(other);
 
                if (!sk_locked)
                        unix_state_lock(sk);
@@ -2104,7 +2103,6 @@ restart_locked:
                                err = -ECONNRESET;
                }
 
-               other = NULL;
                if (err)
                        goto out_free;