Skip to content

Commit a54d405

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrdma: Chunk list encoders must not return zero
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 <[email protected]> Tested-by: Steve Wise <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 7a89f9c commit a54d405

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

net/sunrpc/xprtrdma/fmr_ops.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
246246
}
247247
mw->mw_nents = i;
248248
mw->mw_dir = rpcrdma_data_dir(writing);
249+
if (i == 0)
250+
goto out_dmamap_err;
249251

250252
if (!ib_dma_map_sg(r_xprt->rx_ia.ri_device,
251253
mw->mw_sg, mw->mw_nents, mw->mw_dir))

net/sunrpc/xprtrdma/frwr_ops.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ frwr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
411411
}
412412
mw->mw_nents = i;
413413
mw->mw_dir = rpcrdma_data_dir(writing);
414+
if (i == 0)
415+
goto out_dmamap_err;
414416

415417
dma_nents = ib_dma_map_sg(ia->ri_device,
416418
mw->mw_sg, mw->mw_nents, mw->mw_dir);

net/sunrpc/xprtrdma/rpc_rdma.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ rpcrdma_encode_read_list(struct rpcrdma_xprt *r_xprt,
329329

330330
do {
331331
n = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs, false);
332-
if (n <= 0)
332+
if (n < 0)
333333
return ERR_PTR(n);
334334

335335
*iptr++ = xdr_one; /* item present */
@@ -397,7 +397,7 @@ rpcrdma_encode_write_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
397397
nchunks = 0;
398398
do {
399399
n = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs, true);
400-
if (n <= 0)
400+
if (n < 0)
401401
return ERR_PTR(n);
402402

403403
iptr = xdr_encode_rdma_segment(iptr, seg);
@@ -462,7 +462,7 @@ rpcrdma_encode_reply_chunk(struct rpcrdma_xprt *r_xprt,
462462
nchunks = 0;
463463
do {
464464
n = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs, true);
465-
if (n <= 0)
465+
if (n < 0)
466466
return ERR_PTR(n);
467467

468468
iptr = xdr_encode_rdma_segment(iptr, seg);

0 commit comments

Comments
 (0)