Skip to content

Commit 1781481

Browse files
author
Trond Myklebust
committed
SUNRPC: Fix call completion races with call_decode()
We need to make sure that the req->rq_private_buf is completely up to date before we make req->rq_reply_bytes_recvd visible to the call_decode() routine in order to avoid triggering the WARN_ON(). Reported-by: Benjamin Coddington <[email protected]> Fixes: 72691a2 ("SUNRPC: Don't reuse bvec on retransmission of the request") Tested-by: Benjamin Coddington <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent ed06fce commit 1781481

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/sunrpc/xprt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,11 +1179,8 @@ xprt_request_dequeue_receive_locked(struct rpc_task *task)
11791179
{
11801180
struct rpc_rqst *req = task->tk_rqstp;
11811181

1182-
if (test_and_clear_bit(RPC_TASK_NEED_RECV, &task->tk_runstate)) {
1182+
if (test_and_clear_bit(RPC_TASK_NEED_RECV, &task->tk_runstate))
11831183
xprt_request_rb_remove(req->rq_xprt, req);
1184-
xdr_free_bvec(&req->rq_rcv_buf);
1185-
req->rq_private_buf.bvec = NULL;
1186-
}
11871184
}
11881185

11891186
/**
@@ -1221,6 +1218,8 @@ void xprt_complete_rqst(struct rpc_task *task, int copied)
12211218

12221219
xprt->stat.recvs++;
12231220

1221+
xdr_free_bvec(&req->rq_rcv_buf);
1222+
req->rq_private_buf.bvec = NULL;
12241223
req->rq_private_buf.len = copied;
12251224
/* Ensure all writes are done before we update */
12261225
/* req->rq_reply_bytes_recvd */
@@ -1453,6 +1452,7 @@ xprt_request_dequeue_xprt(struct rpc_task *task)
14531452
xprt_request_dequeue_transmit_locked(task);
14541453
xprt_request_dequeue_receive_locked(task);
14551454
spin_unlock(&xprt->queue_lock);
1455+
xdr_free_bvec(&req->rq_rcv_buf);
14561456
}
14571457
}
14581458

0 commit comments

Comments
 (0)