| .. | .. |
|---|
| 386 | 386 | struct p9_trans_rdma *rdma = client->trans; |
|---|
| 387 | 387 | struct ib_recv_wr wr; |
|---|
| 388 | 388 | struct ib_sge sge; |
|---|
| 389 | + int ret; |
|---|
| 389 | 390 | |
|---|
| 390 | 391 | c->busa = ib_dma_map_single(rdma->cm_id->device, |
|---|
| 391 | 392 | c->rc.sdata, client->msize, |
|---|
| .. | .. |
|---|
| 403 | 404 | wr.wr_cqe = &c->cqe; |
|---|
| 404 | 405 | wr.sg_list = &sge; |
|---|
| 405 | 406 | wr.num_sge = 1; |
|---|
| 406 | | - return ib_post_recv(rdma->qp, &wr, NULL); |
|---|
| 407 | + |
|---|
| 408 | + ret = ib_post_recv(rdma->qp, &wr, NULL); |
|---|
| 409 | + if (ret) |
|---|
| 410 | + ib_dma_unmap_single(rdma->cm_id->device, c->busa, |
|---|
| 411 | + client->msize, DMA_FROM_DEVICE); |
|---|
| 412 | + return ret; |
|---|
| 407 | 413 | |
|---|
| 408 | 414 | error: |
|---|
| 409 | 415 | p9_debug(P9_DEBUG_ERROR, "EIO\n"); |
|---|
| .. | .. |
|---|
| 500 | 506 | |
|---|
| 501 | 507 | if (down_interruptible(&rdma->sq_sem)) { |
|---|
| 502 | 508 | err = -EINTR; |
|---|
| 503 | | - goto send_error; |
|---|
| 509 | + goto dma_unmap; |
|---|
| 504 | 510 | } |
|---|
| 505 | 511 | |
|---|
| 506 | 512 | /* Mark request as `sent' *before* we actually send it, |
|---|
| .. | .. |
|---|
| 510 | 516 | req->status = REQ_STATUS_SENT; |
|---|
| 511 | 517 | err = ib_post_send(rdma->qp, &wr, NULL); |
|---|
| 512 | 518 | if (err) |
|---|
| 513 | | - goto send_error; |
|---|
| 519 | + goto dma_unmap; |
|---|
| 514 | 520 | |
|---|
| 515 | 521 | /* Success */ |
|---|
| 516 | 522 | return 0; |
|---|
| 517 | 523 | |
|---|
| 524 | +dma_unmap: |
|---|
| 525 | + ib_dma_unmap_single(rdma->cm_id->device, c->busa, |
|---|
| 526 | + c->req->tc.size, DMA_TO_DEVICE); |
|---|
| 518 | 527 | /* Handle errors that happened during or while preparing the send: */ |
|---|
| 519 | 528 | send_error: |
|---|
| 520 | 529 | req->status = REQ_STATUS_ERROR; |
|---|