[3/5] 9p: fix error handle in 'post_recv()'
Commit Message
From: Ye Bin <yebin10@huawei.com>
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@huawei.com>
---
net/9p/trans_rdma.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
@@ -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)