[PATCH v1 14/19] nvme-rdma: Fix error check for ib_dma_map_sg

From: Jack Wang
Date: Fri Aug 19 2022 - 02:09:40 EST


ib_dma_map_sg return 0 on error.

Cc: Keith Busch <kbusch@xxxxxxxxxx>
Cc: Jens Axboe <axboe@xxxxxx>
Cc: Christoph Hellwig <hch@xxxxxx>
Cc: Sagi Grimberg <sagi@xxxxxxxxxxx>
Cc: linux-nvme@xxxxxxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx

Signed-off-by: Jack Wang <jinpu.wang@xxxxxxxxx>
---
drivers/nvme/host/rdma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 3100643be299..d70bccbcba3e 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1551,7 +1551,7 @@ static int nvme_rdma_dma_map_req(struct ib_device *ibdev, struct request *rq,

*count = ib_dma_map_sg(ibdev, req->data_sgl.sg_table.sgl,
req->data_sgl.nents, rq_dma_dir(rq));
- if (unlikely(*count <= 0)) {
+ if (unlikely(!*count)) {
ret = -EIO;
goto out_free_table;
}
@@ -1574,7 +1574,7 @@ static int nvme_rdma_dma_map_req(struct ib_device *ibdev, struct request *rq,
req->metadata_sgl->sg_table.sgl,
req->metadata_sgl->nents,
rq_dma_dir(rq));
- if (unlikely(*pi_count <= 0)) {
+ if (unlikely(!*pi_count)) {
ret = -EIO;
goto out_free_pi_table;
}
--
2.34.1