mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
SUNRPC: Fix locking around callback channel reply receive
commit 093a1468b6
upstream.
Both xprt_lookup_rqst() and xprt_complete_rqst() require that you
take the transport lock in order to avoid races with xprt_transmit().
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Reviewed-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
[lizf: Backported to 3.4: adjust context]
Signed-off-by: Zefan Li <lizefan@huawei.com>
This commit is contained in:
parent
7167d33601
commit
63ed3573ab
1 changed files with 16 additions and 11 deletions
|
@ -1055,17 +1055,12 @@ static int receive_cb_reply(struct svc_sock *svsk, struct svc_rqst *rqstp)
|
|||
xid = *p++;
|
||||
calldir = *p;
|
||||
|
||||
if (bc_xprt)
|
||||
req = xprt_lookup_rqst(bc_xprt, xid);
|
||||
|
||||
if (!req) {
|
||||
printk(KERN_NOTICE
|
||||
"%s: Got unrecognized reply: "
|
||||
"calldir 0x%x xpt_bc_xprt %p xid %08x\n",
|
||||
__func__, ntohl(calldir),
|
||||
bc_xprt, xid);
|
||||
if (!bc_xprt)
|
||||
return -EAGAIN;
|
||||
}
|
||||
spin_lock_bh(&bc_xprt->transport_lock);
|
||||
req = xprt_lookup_rqst(bc_xprt, xid);
|
||||
if (!req)
|
||||
goto unlock_notfound;
|
||||
|
||||
memcpy(&req->rq_private_buf, &req->rq_rcv_buf, sizeof(struct xdr_buf));
|
||||
/*
|
||||
|
@ -1076,11 +1071,21 @@ static int receive_cb_reply(struct svc_sock *svsk, struct svc_rqst *rqstp)
|
|||
dst = &req->rq_private_buf.head[0];
|
||||
src = &rqstp->rq_arg.head[0];
|
||||
if (dst->iov_len < src->iov_len)
|
||||
return -EAGAIN; /* whatever; just giving up. */
|
||||
goto unlock_eagain; /* whatever; just giving up. */
|
||||
memcpy(dst->iov_base, src->iov_base, src->iov_len);
|
||||
xprt_complete_rqst(req->rq_task, svsk->sk_reclen);
|
||||
rqstp->rq_arg.len = 0;
|
||||
spin_unlock_bh(&bc_xprt->transport_lock);
|
||||
return 0;
|
||||
unlock_notfound:
|
||||
printk(KERN_NOTICE
|
||||
"%s: Got unrecognized reply: "
|
||||
"calldir 0x%x xpt_bc_xprt %p xid %08x\n",
|
||||
__func__, ntohl(calldir),
|
||||
bc_xprt, ntohl(xid));
|
||||
unlock_eagain:
|
||||
spin_unlock_bh(&bc_xprt->transport_lock);
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
static int copy_pages_to_kvecs(struct kvec *vec, struct page **pages, int len)
|
||||
|
|
Loading…
Reference in a new issue