[PATCH 3/5] 9p: fix error handle in 'post_recv()'

From: Ye Bin
Date: Mon Nov 21 2022 - 02:39:50 EST


From: Ye Bin <yebin10@xxxxxxxxxx>

There are two issues in 'post_recv()':
1. Miss unmap request if receive request failed;
2. Miss release 'rdma->rq_sem' if post receive failed or mapping failed;

So add miss release 'rdma->rq_sem' and unmap request when do error handle.

Signed-off-by: Ye Bin <yebin10@xxxxxxxxxx>
---
net/9p/trans_rdma.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
index ae2bac9bf510..bcab550c2e2c 100644
--- a/net/9p/trans_rdma.c
+++ b/net/9p/trans_rdma.c
@@ -386,6 +386,7 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c)
struct p9_trans_rdma *rdma = client->trans;
struct ib_recv_wr wr;
struct ib_sge sge;
+ int err = -EIO;

c->busa = ib_dma_map_single(rdma->cm_id->device,
c->rc.sdata, client->msize,
@@ -403,11 +404,17 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c)
wr.wr_cqe = &c->cqe;
wr.sg_list = &sge;
wr.num_sge = 1;
- return ib_post_recv(rdma->qp, &wr, NULL);
-
+ err = ib_post_recv(rdma->qp, &wr, NULL);
+ if (err) {
+ ib_dma_unmap_single(rdma->cm_id->device, c->busa,
+ client->msize, DMA_FROM_DEVICE);
+ goto error;
+ }
+ return 0;
error:
+ up(&rdma->rq_sem);
p9_debug(P9_DEBUG_ERROR, "EIO\n");
- return -EIO;
+ return err;
}

static int rdma_request(struct p9_client *client, struct p9_req_t *req)
--
2.31.1