diff mbox

RDMA/libocrdma: return error if destroy fails

Message ID 12d6c580-1a1f-4da4-b3e1-12b75e2f983b@CMEXHTCAS1.ad.emulex.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Devesh Sharma Jan. 17, 2015, 10:07 a.m. UTC
From: Padmanabh Ratnakar <padmanabh.ratnakar@emulex.com>

If the destorying of any resource has failed at uverbs
command interface libocrdma should return the error code.

Signed-off-by: Padmanabh Ratnakar <padmanabh.ratnakar@emulex.com>
Signed-off-by: Devesh Sharma <devesh.sharma@emulex.com>
---
 src/ocrdma_verbs.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/src/ocrdma_verbs.c b/src/ocrdma_verbs.c
index c089a5f..cf2ecd2 100644
--- a/src/ocrdma_verbs.c
+++ b/src/ocrdma_verbs.c
@@ -209,10 +209,11 @@  int ocrdma_free_pd(struct ibv_pd *ibpd)
 	struct ocrdma_pd *pd = get_ocrdma_pd(ibpd);
 
 	status = ibv_cmd_dealloc_pd(ibpd);
-	if (pd->dpp_va)
-		munmap((void *)pd->dpp_va, OCRDMA_DPP_PAGE_SIZE);
 	if (status)
 		return status;
+
+	if (pd->dpp_va)
+		munmap((void *)pd->dpp_va, OCRDMA_DPP_PAGE_SIZE);
 	free(pd);
 	return 0;
 }
@@ -356,8 +357,12 @@  int ocrdma_resize_cq(struct ibv_cq *ibcq, int new_entries)
 int ocrdma_destroy_cq(struct ibv_cq *ibv_cq)
 {
 	struct ocrdma_cq *cq = get_ocrdma_cq(ibv_cq);
+	int status;
+
+	status = ibv_cmd_destroy_cq(ibv_cq);
+	if (status)
+		return status;
 
-	ibv_cmd_destroy_cq(ibv_cq);
 	if (cq->db_va)
 		munmap((void *)cq->db_va, cq->db_size);
 	if (cq->va)
@@ -484,6 +489,9 @@  int ocrdma_destroy_srq(struct ibv_srq *ibsrq)
 
 	id = dev->id;
 	status = ibv_cmd_destroy_srq(ibsrq);
+	if (status)
+		return status;
+
 	if (srq->idx_bit_fields)
 		free(srq->idx_bit_fields);
 	if (srq->rqe_wr_id_tbl)