[openib-general] Re: [PATCH] libmthca: fix error handling in mthca_store_qp

Roland Dreier rdreier at cisco.com
Wed Dec 14 12:21:34 PST 2005


Thanks, good catch.  I decided it was clearer to split off the test of
refcnt, and only increment refcnt if the allocation succeeds.

 - R.

--- libmthca/src/qp.c	(revision 4465)
+++ libmthca/src/qp.c	(working copy)
@@ -875,13 +875,15 @@ int mthca_store_qp(struct mthca_context 
 
 	pthread_mutex_lock(&ctx->qp_table_mutex);
 
-	if (!ctx->qp_table[tind].refcnt++) {
+	if (!ctx->qp_table[tind].refcnt) {
 		ctx->qp_table[tind].table = calloc(ctx->qp_table_mask + 1,
 						   sizeof (struct mthca_qp *));
 		if (!ctx->qp_table[tind].table) {
 			ret = -1;
 			goto out;
 		}
+
+		++ctx->qp_table[tind].refcnt;
 	}
 
 	ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = qp;
--- libmthca/ChangeLog	(revision 4465)
+++ libmthca/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2005-12-14  Roland Dreier  <rdreier at cisco.com>
+
+	* src/qp.c (mthca_store_qp): Only increment qp_table ref count if
+	allocation succeeds.
+
 2005-11-29  Michael S. Tsirkin  <mst at mellanox.co.il>
 
 	* src/qp.c (mthca_arbel_post_send): Add handling for posting long



More information about the general mailing list