[openib-general] [PATCH resend] libamso: fix erroneous return and memory leak in verbs.c

Pradipta Kumar Banerjee bpradip at in.ibm.com
Tue Jun 13 10:55:07 PDT 2006


Forgot to add the 'Signed-off-by'

This patch fixes an erroneous return in func amso_create_cq() and a memory
leak in amso_create_qp().

Signed-off-by: Pradipta Kumar Banerjee <bpradipt at in.ibm.com>

---

Index = libamso/verbs.c
============================================================================
--- verbs.org	2006-06-13 18:56:50.000000000 +0530
+++ verbs.c	2006-06-13 19:02:03.000000000 +0530
@@ -154,9 +154,8 @@ struct ibv_cq *amso_create_cq(struct ibv
 	int ret;
 
 	cq = malloc(sizeof *cq);
-	if (!cq) {
-		goto err;
-	}
+	if (!cq) 
+		return NULL;
 
 	ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector,
 				&cq->ibv_cq, &cmd.ibv_cmd, sizeof cmd,
@@ -248,14 +247,15 @@ struct ibv_qp *amso_create_qp(struct ibv
 	ret = ibv_cmd_create_qp(pd, &qp->ibv_qp, attr, &cmd.ibv_cmd, sizeof cmd,
 				&resp.ibv_resp, sizeof resp);
 	if (ret)
-		return NULL;
+		goto err;
 
 #if 0 /* A reminder for bypass functionality */
 	qp->physaddr = resp.physaddr;
 #endif
 
 	return &qp->ibv_qp;
-
+err:
+	free(qp);
 
 	return NULL;
 }




More information about the general mailing list