xprtrdma: Chunk list encoders must not return zero
authorChuck Lever <chuck.lever@oracle.com>
Wed, 29 Jun 2016 17:53:52 +0000 (13:53 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Mon, 11 Jul 2016 19:50:43 +0000 (15:50 -0400)
Clean up, based on code audit: Remove the possibility that the
chunk list XDR encoders can return zero, which would be interpreted
as a NULL.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/xprtrdma/fmr_ops.c
net/sunrpc/xprtrdma/frwr_ops.c
net/sunrpc/xprtrdma/rpc_rdma.c

index aae4c372a40fa13e77662f2d80c2c1a4cb32acf9..bc5f4a1e31226ffaa874baed0c0f447ff3e97e7a 100644 (file)
@@ -246,6 +246,8 @@ fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
        }
        mw->mw_nents = i;
        mw->mw_dir = rpcrdma_data_dir(writing);
+       if (i == 0)
+               goto out_dmamap_err;
 
        if (!ib_dma_map_sg(r_xprt->rx_ia.ri_device,
                           mw->mw_sg, mw->mw_nents, mw->mw_dir))
index d7613db9185d0c43ebe0d130974c02b9b98c543d..f3a06faf0a18fb149f965af253304ceddbacad92 100644 (file)
@@ -411,6 +411,8 @@ frwr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
        }
        mw->mw_nents = i;
        mw->mw_dir = rpcrdma_data_dir(writing);
+       if (i == 0)
+               goto out_dmamap_err;
 
        dma_nents = ib_dma_map_sg(ia->ri_device,
                                  mw->mw_sg, mw->mw_nents, mw->mw_dir);
index 77e002f4d005512b0f6eb366433b1e8ac52e10e7..8fde0ab3b6958d1663d71be0416748d78b28827d 100644 (file)
@@ -329,7 +329,7 @@ rpcrdma_encode_read_list(struct rpcrdma_xprt *r_xprt,
 
        do {
                n = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs, false);
-               if (n <= 0)
+               if (n < 0)
                        return ERR_PTR(n);
 
                *iptr++ = xdr_one;      /* item present */
@@ -397,7 +397,7 @@ rpcrdma_encode_write_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
        nchunks = 0;
        do {
                n = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs, true);
-               if (n <= 0)
+               if (n < 0)
                        return ERR_PTR(n);
 
                iptr = xdr_encode_rdma_segment(iptr, seg);
@@ -462,7 +462,7 @@ rpcrdma_encode_reply_chunk(struct rpcrdma_xprt *r_xprt,
        nchunks = 0;
        do {
                n = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs, true);
-               if (n <= 0)
+               if (n < 0)
                        return ERR_PTR(n);
 
                iptr = xdr_encode_rdma_segment(iptr, seg);