[MTHCA] bugfix: destroy spinlock object
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 20 Sep 2006 11:44:38 +0000 (11:44 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 20 Sep 2006 11:44:38 +0000 (11:44 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@500 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mthca/user/mlnx_uvp_verbs.c

index 847143d..783ff72 100644 (file)
@@ -117,7 +117,7 @@ struct ibv_cq *mthca_create_cq_pre(struct ibv_context *context, int *p_cqe,
 
        if (posix_memalign(&cq->buf, g_page_size,
                        align(nent * MTHCA_CQ_ENTRY_SIZE, g_page_size)))
-               goto err;
+               goto err_memalign;
 
        mthca_init_cq_buf(cq, nent);
 
@@ -181,8 +181,12 @@ err_set_db:
 err_unreg:
        cl_free(cq->buf);
 
+err_memalign:
+       cl_spinlock_destroy(&cq->lock);
+
 err:
        cl_free(cq);
+       
 exit:
        return ERR_PTR(-ENOMEM);
 }
@@ -296,11 +300,17 @@ struct ibv_qp *mthca_create_qp_pre(struct ibv_pd *pd,
        mthca_init_qp_indices(qp);
 
        cl_spinlock_construct(&qp->sq.lock);
+       if (cl_spinlock_init(&qp->sq.lock)) {
+               ret = -EFAULT;
+               UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_QP ,("cl_spinlock_init failed for sq (%d)\n",ret));
+               goto err_spinlock_sq;
+       }
+
        cl_spinlock_construct(&qp->rq.lock);
-       if (cl_spinlock_init(&qp->sq.lock) || cl_spinlock_init(&qp->rq.lock)) {
+       if (cl_spinlock_init(&qp->rq.lock)) {
                ret = -EFAULT;
-               UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_QP ,("cl_spinlock_init failed (%d)\n",ret));
-               goto err_spinlock;
+               UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_QP ,("cl_spinlock_init failed for rq (%d)\n",ret));
+               goto err_spinlock_rq;
        }
 
        if (mthca_is_memfree(context)) {
@@ -308,13 +318,13 @@ struct ibv_qp *mthca_create_qp_pre(struct ibv_pd *pd,
                                                 MTHCA_DB_TYPE_SQ,
                                                 &qp->sq.db);
                if (qp->sq.db_index < 0)
-                       goto err_spinlock;
+                       goto err_sq_db;
 
                qp->rq.db_index = mthca_alloc_db(to_mctx(context)->db_tab,
                                                 MTHCA_DB_TYPE_RQ,
                                                 &qp->rq.db);
                if (qp->rq.db_index < 0)
-                       goto err_sq_db;
+                       goto err_rq_db;
 
                req->sq_db_page  = db_align(qp->sq.db);
                req->rq_db_page  = db_align(qp->rq.db);
@@ -354,12 +364,18 @@ struct ibv_qp *mthca_create_qp_pre(struct ibv_pd *pd,
        UVP_EXIT(UVP_DBG_QP);
        return &qp->ibv_qp;
 
-err_sq_db:
+err_rq_db:
        if (mthca_is_memfree(context))
                mthca_free_db(to_mctx(context)->db_tab, 
                        MTHCA_DB_TYPE_SQ, qp->sq.db_index);
 
-err_spinlock:
+err_sq_db:
+       cl_spinlock_destroy(&qp->rq.lock);
+
+err_spinlock_rq:
+       cl_spinlock_destroy(&qp->sq.lock);
+       
+err_spinlock_sq:
        cl_free(qp->wrid);
 #ifdef NOT_USE_VIRTUAL_ALLOC   
        cl_free(qp->buf);