aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@mellanox.co.il>2005-12-15 16:11:18 +0000
committerRoland Dreier <rolandd@cisco.com>2006-11-09 19:57:04 -0800
commit182c04e4c642169d17e4415240be0a57b01d8567 (patch)
tree1f2adae439765104f98973724da98b1c13cd47f9
parent33efbbddefb44fba3cc6fd9ef726567433f3912c (diff)
downloadlibmthca-182c04e4c642169d17e4415240be0a57b01d8567.tar.gz
Only increment qp_table ref count if allocation succeeds
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il> Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--ChangeLog5
-rw-r--r--src/qp.c3
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 4c2e202..fa90316 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-12-15 Michael S. Tsirkin <mst@mellanox.co.il>
+
+ * src/qp.c (mthca_store_qp): Don't increment qp_table ref count if
+ allocation fails.
+
2005-11-29 Michael S. Tsirkin <mst@mellanox.co.il>
* src/qp.c (mthca_arbel_post_send): Add handling for posting long
diff --git a/src/qp.c b/src/qp.c
index 9170b37..caf8a86 100644
--- a/src/qp.c
+++ b/src/qp.c
@@ -875,7 +875,7 @@ int mthca_store_qp(struct mthca_context *ctx, uint32_t qpn, struct mthca_qp *qp)
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) {
@@ -884,6 +884,7 @@ int mthca_store_qp(struct mthca_context *ctx, uint32_t qpn, struct mthca_qp *qp)
}
}
+ ++ctx->qp_table[tind].refcnt;
ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = qp;
out: