[MTHCA] bugfix: passing huge size values to create_cq/resize_cq causes hang in align_...
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 14 Aug 2006 17:05:44 +0000 (17:05 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 14 Aug 2006 17:05:44 +0000 (17:05 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@448 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mthca/user/mlnx_uvp_verbs.c

index 40a360d..c321cec 100644 (file)
@@ -100,6 +100,10 @@ struct ibv_cq *mthca_create_cq_pre(struct ibv_context *context, int *p_cqe,
        int                         nent;
        int                         ret;
 
+       /* Sanity check CQ size before proceeding */
+       if (*p_cqe > 131072)
+               goto exit;
+
        cq = cl_malloc(sizeof *cq);
        if (!cq)
                goto exit;
@@ -112,7 +116,7 @@ struct ibv_cq *mthca_create_cq_pre(struct ibv_context *context, int *p_cqe,
                ; /* nothing */
 
        if (posix_memalign(&cq->buf, g_page_size,
-                          align(nent * MTHCA_CQ_ENTRY_SIZE, g_page_size)))
+                       align(nent * MTHCA_CQ_ENTRY_SIZE, g_page_size)))
                goto err;
 
        mthca_init_cq_buf(cq, nent);
@@ -167,12 +171,12 @@ struct ibv_cq *mthca_create_cq_pre(struct ibv_context *context, int *p_cqe,
 err_arm_db:
        if (mthca_is_memfree(context))
                mthca_free_db(to_mctx(context)->db_tab, MTHCA_DB_TYPE_CQ_SET_CI,
-                             cq->arm_db_index);
+                       cq->arm_db_index);
 
 err_set_db:
        if (mthca_is_memfree(context))
                mthca_free_db(to_mctx(context)->db_tab, MTHCA_DB_TYPE_CQ_SET_CI,
-                             cq->set_ci_db_index);
+                       cq->set_ci_db_index);
 
 err_unreg:
        cl_free(cq->buf);