[MLX4] skip allocation of WRID array for zero-size RQ or SQ.
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sun, 28 Sep 2008 15:11:13 +0000 (15:11 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sun, 28 Sep 2008 15:11:13 +0000 (15:11 +0000)
Suggested by: Alex Estrin

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@1625 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mlx4/kernel/bus/ib/qp.c

index 38a9d32..18ebc9e 100644 (file)
@@ -412,8 +412,11 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
                if (err)\r
                        goto err_mtt;\r
 \r
-               qp->sq.wrid  = kmalloc(qp->sq.wqe_cnt * sizeof (u64), GFP_KERNEL);\r
-               qp->rq.wrid  = kmalloc(qp->rq.wqe_cnt * sizeof (u64), GFP_KERNEL);\r
+               if (qp->sq.wqe_cnt)\r
+                       qp->sq.wrid  = kmalloc(qp->sq.wqe_cnt * sizeof (u64), GFP_KERNEL);\r
+\r
+               if (qp->rq.wqe_cnt)\r
+                       qp->rq.wrid  = kmalloc(qp->rq.wqe_cnt * sizeof (u64), GFP_KERNEL);\r
 \r
                if (!qp->sq.wrid || !qp->rq.wrid) {\r
                        err = -ENOMEM;\r
@@ -452,8 +455,10 @@ err_wrid:
                        mlx4_ib_db_unmap_user(to_mucontext(pd->p_uctx),\r
                                              &qp->db);\r
        } else {\r
-               kfree(qp->sq.wrid);\r
-               kfree(qp->rq.wrid);\r
+               if (qp->sq.wrid)\r
+                       kfree(qp->sq.wrid);\r
+               if (qp->rq.wrid)\r
+                       kfree(qp->rq.wrid);\r
        }\r
 \r
 err_mtt:\r