aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2017-08-01 12:00:14 -0400
committerJ. Bruce Fields <bfields@redhat.com>2017-08-24 22:13:50 -0400
commit7075a867ce5748007b299bd28f12754cd51719d4 (patch)
treeb009fd5045e9ff602bb1682944b2e053ea23e37b
parentafea5657c20b11ec9f895ac5cc33b560fb1e0276 (diff)
svcrdma: Clean up svc_rdma_build_read_chunk()
Dan Carpenter <dan.carpenter@oracle.com> observed that the while() loop in svc_rdma_build_read_chunk() does not document the assumption that the loop interior is always executed at least once. Defensive: the function now returns -EINVAL if this assumption fails. Suggested-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r--net/sunrpc/xprtrdma/svc_rdma_rw.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/net/sunrpc/xprtrdma/svc_rdma_rw.c b/net/sunrpc/xprtrdma/svc_rdma_rw.c
index 933f79bed270..1f34fae7aec0 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_rw.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_rw.c
@@ -660,19 +660,21 @@ out_initerr:
660 return -EIO; 660 return -EIO;
661} 661}
662 662
663/* Walk the segments in the Read chunk starting at @p and construct
664 * RDMA Read operations to pull the chunk to the server.
665 */
663static int svc_rdma_build_read_chunk(struct svc_rqst *rqstp, 666static int svc_rdma_build_read_chunk(struct svc_rqst *rqstp,
664 struct svc_rdma_read_info *info, 667 struct svc_rdma_read_info *info,
665 __be32 *p) 668 __be32 *p)
666{ 669{
667 int ret; 670 int ret;
668 671
672 ret = -EINVAL;
669 info->ri_chunklen = 0; 673 info->ri_chunklen = 0;
670 while (*p++ != xdr_zero) { 674 while (*p++ != xdr_zero && be32_to_cpup(p++) == info->ri_position) {
671 u32 rs_handle, rs_length; 675 u32 rs_handle, rs_length;
672 u64 rs_offset; 676 u64 rs_offset;
673 677
674 if (be32_to_cpup(p++) != info->ri_position)
675 break;
676 rs_handle = be32_to_cpup(p++); 678 rs_handle = be32_to_cpup(p++);
677 rs_length = be32_to_cpup(p++); 679 rs_length = be32_to_cpup(p++);
678 p = xdr_decode_hyper(p, &rs_offset); 680 p = xdr_decode_hyper(p, &rs_offset);