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
This commit is contained in:
Rick Macklem committed 2026-10-04 13:29:43 -07:00
1 parent a127039dd0
commit 81a6514689
1 file changed
+8 -2
+8 -2
View File
@@ -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. */