]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
IB/mthca: Fix error path in mthca_alloc_memfree()
authorRoland Dreier <rolandd@cisco.com>
Thu, 1 Mar 2007 21:17:14 +0000 (13:17 -0800)
committerRoland Dreier <rolandd@cisco.com>
Thu, 1 Mar 2007 21:17:14 +0000 (13:17 -0800)
The garbled logic in mthca_alloc_memfree() causes it to return 0, even
if it fails to allocate all doorbell records.  Fix it to return -ENOMEM
when it fails.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/mthca/mthca_qp.c

index 71dc84bd425498cd968a33cfa6e005804861474f..1c6b63aca26846c04537ba92eea18af88ec7f058 100644 (file)
@@ -1088,21 +1088,21 @@ static void mthca_unmap_memfree(struct mthca_dev *dev,
 static int mthca_alloc_memfree(struct mthca_dev *dev,
                               struct mthca_qp *qp)
 {
-       int ret = 0;
-
        if (mthca_is_memfree(dev)) {
                qp->rq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_RQ,
                                                 qp->qpn, &qp->rq.db);
                if (qp->rq.db_index < 0)
-                       return ret;
+                       return -ENOMEM;
 
                qp->sq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SQ,
                                                 qp->qpn, &qp->sq.db);
-               if (qp->sq.db_index < 0)
+               if (qp->sq.db_index < 0) {
                        mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index);
+                       return -ENOMEM;
+               }
        }
 
-       return ret;
+       return 0;
 }
 
 static void mthca_free_memfree(struct mthca_dev *dev,