git: acea8d0466f3 - releng/14.4 - socket: remove tautological condition in so_unsplice()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 17 Nov 2026 17:04:17 UTC
The branch releng/14.4 has been updated by markj:

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

commit acea8d0466f3c413ac42bc2776f3677383c82727
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2026-06-19 04:03:30 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-16 21:16:22 +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.
    
    Approved by:    so
    Security:       FreeBSD-SA-26:87.socket
    Reviewed by:    gallatin, markj
    Differential Revision:  https://reviews.freebsd.org/D57558
    
    (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 f9ce5446f459..c90fe0196aa8 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1746,7 +1746,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
@@ -1791,7 +1791,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);
@@ -1837,8 +1836,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);