git: 2b25a0ebb48d - stable/15 - socket: remove tautological condition in so_unsplice()

Kyle Evans <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src,gmane.os.freebsd.devel.stable.scm
Message-ID <[email protected]>
The branch stable/15 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=2b25a0ebb48dc2340e1e15d1a05b89d7df036b38

commit 2b25a0ebb48dc2340e1e15d1a05b89d7df036b38
Author:     Kyle Evans <[email protected]>
AuthorDate: 2026-06-19 04:03:30 +0000
Commit:     Kyle Evans <[email protected]>
CommitDate: 2026-08-06 23:34:46 +0000

    socket: remove tautological condition in so_unsplice()
    
    so2rele was introduced in 1000cc4a0d3 and it was necessary there, but
    the cleanup in a837d1fe49e0255 rendered it redundant if our own KASSERT
    is to be believed: we've asserted that `so2->so_splice_back == sp` and
    `sp` has been dereferenced above, so there's no condition left where
    we shouldn't release the socket reference at the end.  Indeed, the
    change in so_splice() to NULL out sp->dst removes that possible state of
    a partially constructed splice: if sp->dst is set, it has been ref'd.
    
    Reviewed by:    gallatin, markj
    
    (cherry picked from commit 8a3d28375450946e4b0de239c9239df54c22d298)
---
 sys/kern/uipc_socket.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index d2ad4e147da5..11d7e794da00 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1773,7 +1773,7 @@ so_unsplice(struct socket *so, bool timeout)
 {
 	struct socket *so2;
 	struct so_splice *sp;
-	bool drain, so2rele;
+	bool drain;
 
 	/*
 	 * First unset SB_SPLICED and hide the splice structure so that
@@ -1818,7 +1818,6 @@ so_unsplice(struct socket *so, bool timeout)
 		KASSERT(so2->so_splice_back == sp,
 		    ("%s: so_splice_back != sp", __func__));
 		so2->so_snd.sb_flags &= ~SB_SPLICED;
-		so2rele = so2->so_splice_back != NULL;
 		so2->so_splice_back = NULL;
 		SOCK_SENDBUF_UNLOCK(so2);
 		SOCK_UNLOCK(so2);
@@ -1864,8 +1863,7 @@ so_unsplice(struct socket *so, bool timeout)
 	sorele(so);
 	if (so2 != NULL) {
 		sowwakeup(so2);
-		if (so2rele)
-			sorele(so2);
+		sorele(so2);
 	}
 	CURVNET_RESTORE();
 	so_splice_free(sp);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.