git: 505f381cb96e - main - nvmf_che: Don't leak a socket if an error occurs finalizing the socket

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Mon, 20 Apr 2026 17:20:23 UTC
The branch main has been updated by jhb:

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

commit 505f381cb96ee25bcf0df11cfaf15a601d969500
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2026-04-20 17:18:04 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-04-20 17:18:04 +0000

    nvmf_che: Don't leak a socket if an error occurs finalizing the socket
    
    If soreserve() or sosetopt() (to set TCP_NODELAY) fails after claiming
    the socket from the file descriptor, explicitly close the socket
    before returning failure.
    
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D55493
---
 sys/dev/cxgbe/nvmf/nvmf_che.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/dev/cxgbe/nvmf/nvmf_che.c b/sys/dev/cxgbe/nvmf/nvmf_che.c
index afdfc2f1b758..be54e7bebfea 100644
--- a/sys/dev/cxgbe/nvmf/nvmf_che.c
+++ b/sys/dev/cxgbe/nvmf/nvmf_che.c
@@ -2605,6 +2605,7 @@ che_allocate_qpair(bool controller, const nvlist_t *nvl)
 		free(qp->fl_cids, M_NVMF_CHE);
 		free(qp->open_fl_ttags, M_NVMF_CHE);
 		free(qp, M_NVMF_CHE);
+		soclose(so);
 		return (NULL);
 	}