[openib-general] [PATCH] libamso: fix erroneous return and memory leak in verbs.c
Pradipta Kumar Banerjee
bpradip at in.ibm.com
Tue Jun 13 06:47:51 PDT 2006
Hi,
This patch fixes an erroneous return in func amso_create_cq() and a memory
leak in amso_create_qp()
---
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