The branch main has been updated by rmacklem:

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

commit 81a6514689cefdaa5c92b5539ae885ec8c6b3336
Author:     Rick Macklem <[email protected]>
AuthorDate: 2026-10-04 20:29:43 +0000
Commit:     Rick Macklem <[email protected]>
CommitDate: 2026-10-04 20:29:43 +0000

    clnt_vc.c: Fix handling of backchannel xprt
    
    When clnt_vc_destroy() is called, it might not be the
    current connection.  Without this patch, if it is not
    the current connection, xp_p2 is set NULL and xprt is released
    when it should not be released.
    
    This patch adds a check for "current connection" to fix
    the problem.  Found during testing to the client RDMA code,
    but could happen for TCP as well.
    
    MFC after:      1 week
---
 sys/rpc/clnt_vc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sys/rpc/clnt_vc.c b/sys/rpc/clnt_vc.c
index e395cd27ccaa..9b12212f9a2e 100644
--- a/sys/rpc/clnt_vc.c
+++ b/sys/rpc/clnt_vc.c
@@ -856,6 +856,7 @@ clnt_vc_destroy(CLIENT *cl)
        struct socket *so;
        SVCXPRT *xprt;
        uint32_t reterr;
+       bool_t rlse;
 
        clnt_vc_close(cl);
 
@@ -864,11 +865,16 @@ clnt_vc_destroy(CLIENT *cl)
        ct->ct_backchannelxprt = NULL;
        if (xprt != NULL) {
                mtx_unlock(&ct->ct_lock);       /* To avoid a LOR. */
+               rlse = FALSE;
                sx_xlock(&xprt->xp_lock);
                mtx_lock(&ct->ct_lock);
-               xprt->xp_p2 = NULL;
+               if (xprt->xp_p2 == ct) {
+                       xprt->xp_p2 = NULL;
+                       rlse = TRUE;
+               }
                sx_xunlock(&xprt->xp_lock);
-               SVC_RELEASE(xprt);
+               if (rlse)
+                       SVC_RELEASE(xprt);
        }
 
        /* Wait for the upcall kthread to terminate. */

Reply via email to