RDMA: Check umem pointer validity prior to release
authorLeon Romanovsky <leonro@mellanox.com>
Sun, 16 Jun 2019 12:05:20 +0000 (15:05 +0300)
committerDoug Ledford <dledford@redhat.com>
Thu, 20 Jun 2019 19:17:59 +0000 (15:17 -0400)
Update ib_umem_release() to behave similarly to kfree() and allow
submitting NULL pointer as safe input to this function.

Fixes: a52c8e2469c3 ("RDMA: Clean destroy CQ in drivers do not return errors")
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
26 files changed:
drivers/infiniband/core/umem.c
drivers/infiniband/hw/bnxt_re/ib_verbs.c
drivers/infiniband/hw/cxgb3/iwch_provider.c
drivers/infiniband/hw/cxgb4/mem.c
drivers/infiniband/hw/efa/efa_verbs.c
drivers/infiniband/hw/hns/hns_roce_cq.c
drivers/infiniband/hw/hns/hns_roce_hw_v1.c
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_mr.c
drivers/infiniband/hw/hns/hns_roce_qp.c
drivers/infiniband/hw/hns/hns_roce_srq.c
drivers/infiniband/hw/i40iw/i40iw_verbs.c
drivers/infiniband/hw/mlx4/cq.c
drivers/infiniband/hw/mlx4/qp.c
drivers/infiniband/hw/mlx4/srq.c
drivers/infiniband/hw/mlx5/cq.c
drivers/infiniband/hw/mlx5/mr.c
drivers/infiniband/hw/mlx5/qp.c
drivers/infiniband/hw/mthca/mthca_provider.c
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
drivers/infiniband/hw/qedr/verbs.c
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c
drivers/infiniband/hw/vmw_pvrdma/pvrdma_mr.c
drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c
drivers/infiniband/sw/rdmavt/mr.c
drivers/infiniband/sw/rxe/rxe_mr.c

index 54628ef879f0ceee39d4c26e592d8d88b4e0a26f..08da840ed7eebc151b67a61b15626d90578dea54 100644 (file)
@@ -361,6 +361,9 @@ static void __ib_umem_release_tail(struct ib_umem *umem)
  */
 void ib_umem_release(struct ib_umem *umem)
 {
+       if (!umem)
+               return;
+
        if (umem->is_odp) {
                ib_umem_odp_release(to_ib_umem_odp(umem));
                __ib_umem_release_tail(umem);
index 44cc5f19df3be38f9f171cd3f7d3d9cd8443c0e1..a91653aabf3899d9c7e3f5dc4be6ab8ff168ac6c 100644 (file)
@@ -805,10 +805,8 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)
                rdev->sqp_ah = NULL;
        }
 
-       if (!IS_ERR_OR_NULL(qp->rumem))
-               ib_umem_release(qp->rumem);
-       if (!IS_ERR_OR_NULL(qp->sumem))
-               ib_umem_release(qp->sumem);
+       ib_umem_release(qp->rumem);
+       ib_umem_release(qp->sumem);
 
        mutex_lock(&rdev->qp_lock);
        list_del(&qp->list);
@@ -1201,12 +1199,8 @@ struct ib_qp *bnxt_re_create_qp(struct ib_pd *ib_pd,
 qp_destroy:
        bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp);
 free_umem:
-       if (udata) {
-               if (qp->rumem)
-                       ib_umem_release(qp->rumem);
-               if (qp->sumem)
-                       ib_umem_release(qp->sumem);
-       }
+       ib_umem_release(qp->rumem);
+       ib_umem_release(qp->sumem);
 fail:
        kfree(qp);
        return ERR_PTR(rc);
@@ -1302,8 +1296,7 @@ void bnxt_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata)
        if (qplib_srq->cq)
                nq = qplib_srq->cq->nq;
        bnxt_qplib_destroy_srq(&rdev->qplib_res, qplib_srq);
-       if (srq->umem)
-               ib_umem_release(srq->umem);
+       ib_umem_release(srq->umem);
        atomic_dec(&rdev->srq_count);
        if (nq)
                nq->budget--;
@@ -1412,8 +1405,7 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq,
        return 0;
 
 fail:
-       if (srq->umem)
-               ib_umem_release(srq->umem);
+       ib_umem_release(srq->umem);
 exit:
        return rc;
 }
@@ -2528,8 +2520,7 @@ void bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
        nq = cq->qplib_cq.nq;
 
        bnxt_qplib_destroy_cq(&rdev->qplib_res, &cq->qplib_cq);
-       if (!cq->umem)
-               ib_umem_release(cq->umem);
+       ib_umem_release(cq->umem);
 
        atomic_dec(&rdev->cq_count);
        nq->budget--;
@@ -2632,8 +2623,7 @@ int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
        return 0;
 
 c2fail:
-       if (udata)
-               ib_umem_release(cq->umem);
+       ib_umem_release(cq->umem);
 fail:
        kfree(cq->cql);
        return rc;
@@ -3340,8 +3330,7 @@ int bnxt_re_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata)
                mr->npages = 0;
                mr->pages = NULL;
        }
-       if (!IS_ERR_OR_NULL(mr->ib_umem))
-               ib_umem_release(mr->ib_umem);
+       ib_umem_release(mr->ib_umem);
 
        kfree(mr);
        atomic_dec(&rdev->mr_count);
index 810fa96af2e9fd82b7137f9eb6a3c1de4f1a43e9..e775c1a1a4506c147dfe369b2edcd7bc8cef68a5 100644 (file)
@@ -346,8 +346,7 @@ static int iwch_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata)
        xa_erase_irq(&rhp->mrs, mmid);
        if (mhp->kva)
                kfree((void *) (unsigned long) mhp->kva);
-       if (mhp->umem)
-               ib_umem_release(mhp->umem);
+       ib_umem_release(mhp->umem);
        pr_debug("%s mmid 0x%x ptr %p\n", __func__, mmid, mhp);
        kfree(mhp);
        return 0;
index fe3733c4026dea96e0ec422d51a9ac0a4d5dcfac..aa772ee0706f9991ced0a0f6644e15f916d9151c 100644 (file)
@@ -808,8 +808,7 @@ int c4iw_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata)
                                  mhp->attr.pbl_size << 3);
        if (mhp->kva)
                kfree((void *) (unsigned long) mhp->kva);
-       if (mhp->umem)
-               ib_umem_release(mhp->umem);
+       ib_umem_release(mhp->umem);
        pr_debug("mmid 0x%x ptr %p\n", mmid, mhp);
        c4iw_put_wr_wait(mhp->wr_waitp);
        kfree(mhp);
index a9372c9e4b3049dc87df1dd1b0ea820fba89284f..5e6e5eb65cff66ea1e93ad5234185e6171b7e531 100644 (file)
@@ -1513,8 +1513,8 @@ int efa_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
                err = efa_com_dereg_mr(&dev->edev, &params);
                if (err)
                        return err;
-               ib_umem_release(mr->umem);
        }
+       ib_umem_release(mr->umem);
 
        kfree(mr);
 
index 7e198c9ffbfea7b8ea73cba267ad5282200e79f9..6b4d8e50aabeb0f3523d62e34e4efe027fe90e28 100644 (file)
@@ -423,9 +423,8 @@ err_dbmap:
 
 err_mtt:
        hns_roce_mtt_cleanup(hr_dev, &hr_cq->hr_buf.hr_mtt);
-       if (udata)
-               ib_umem_release(hr_cq->umem);
-       else
+       ib_umem_release(hr_cq->umem);
+       if (!udata)
                hns_roce_ib_free_cq_buf(hr_dev, &hr_cq->hr_buf,
                                        hr_cq->ib_cq.cqe);
 
@@ -451,9 +450,8 @@ void hns_roce_ib_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
        hns_roce_free_cq(hr_dev, hr_cq);
        hns_roce_mtt_cleanup(hr_dev, &hr_cq->hr_buf.hr_mtt);
 
+       ib_umem_release(hr_cq->umem);
        if (udata) {
-               ib_umem_release(hr_cq->umem);
-
                if (hr_cq->db_en == 1)
                        hns_roce_db_unmap_user(rdma_udata_to_drv_context(
                                                       udata,
index c899879da222139e73dbb25436bfcb2fc780aaae..cb004190ccba45e16381a0329163196d4620d1c7 100644 (file)
@@ -1163,8 +1163,7 @@ free_mr:
        hns_roce_bitmap_free(&hr_dev->mr_table.mtpt_bitmap,
                             key_to_hw_index(mr->key), 0);
 
-       if (mr->umem)
-               ib_umem_release(mr->umem);
+       ib_umem_release(mr->umem);
 
        kfree(mr);
 
@@ -3641,9 +3640,8 @@ int hns_roce_v1_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
 
        hns_roce_mtt_cleanup(hr_dev, &hr_qp->mtt);
 
-       if (udata)
-               ib_umem_release(hr_qp->umem);
-       else {
+       ib_umem_release(hr_qp->umem);
+       if (!udata) {
                kfree(hr_qp->sq.wrid);
                kfree(hr_qp->rq.wrid);
 
@@ -3694,9 +3692,8 @@ static void hns_roce_v1_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
 
        hns_roce_mtt_cleanup(hr_dev, &hr_cq->hr_buf.hr_mtt);
 
-       if (ibcq->uobject)
-               ib_umem_release(hr_cq->umem);
-       else {
+       ib_umem_release(hr_cq->umem);
+       if (!udata) {
                /* Free the buff of stored cq */
                cq_buf_size = (ibcq->cqe + 1) * hr_dev->caps.cq_entry_sz;
                hns_roce_buf_free(hr_dev, cq_buf_size, &hr_cq->hr_buf.hr_buf);
index 5c8551b54444fd5880747262b2cc38f3df4c3fee..edd62b4dc0a03027e0ea3c4f685b970a71f0c2a6 100644 (file)
@@ -4582,7 +4582,6 @@ static int hns_roce_v2_destroy_qp_common(struct hns_roce_dev *hr_dev,
 
                if (hr_qp->rq.wqe_cnt && (hr_qp->rdb_en == 1))
                        hns_roce_db_unmap_user(context, &hr_qp->rdb);
-               ib_umem_release(hr_qp->umem);
        } else {
                kfree(hr_qp->sq.wrid);
                kfree(hr_qp->rq.wrid);
@@ -4590,6 +4589,7 @@ static int hns_roce_v2_destroy_qp_common(struct hns_roce_dev *hr_dev,
                if (hr_qp->rq.wqe_cnt)
                        hns_roce_free_db(hr_dev, &hr_qp->rdb);
        }
+       ib_umem_release(hr_qp->umem);
 
        if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RQ_INLINE) &&
             hr_qp->rq.wqe_cnt) {
index 6db0dae18ab716f89400c0b3ba821c60ebbb1671..adf075183dfb58948d39ccaba30b1051b9f179c8 100644 (file)
@@ -1298,9 +1298,7 @@ int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
        } else {
                hns_roce_mr_free(hr_dev, mr);
 
-               if (mr->umem)
-                       ib_umem_release(mr->umem);
-
+               ib_umem_release(mr->umem);
                kfree(mr);
        }
 
index 99ec5d43b99bef251ee5229763852f5f1a7630be..7e9db823607224c44d22791d7fbb5d839195b94b 100644 (file)
@@ -938,10 +938,9 @@ err_get_bufs:
        hns_roce_free_buf_list(buf_list, hr_qp->region_cnt);
 
 err_alloc_list:
-       if (hr_qp->umem)
-               ib_umem_release(hr_qp->umem);
-       else
+       if (!hr_qp->umem)
                hns_roce_buf_free(hr_dev, hr_qp->buff_size, &hr_qp->hr_buf);
+       ib_umem_release(hr_qp->umem);
 
 err_db:
        if (!udata && hns_roce_qp_has_rq(init_attr) &&
index c222f243953adc4b8a9d8fd9947df98678456ac2..de645be8aa48c483045656db33487e61ec75cc77 100644 (file)
@@ -380,8 +380,7 @@ err_idx_buf:
        hns_roce_mtt_cleanup(hr_dev, &srq->idx_que.mtt);
 
 err_idx_mtt:
-       if (udata)
-               ib_umem_release(srq->idx_que.umem);
+       ib_umem_release(srq->idx_que.umem);
 
 err_create_idx:
        hns_roce_buf_free(hr_dev, srq->idx_que.buf_size,
@@ -392,9 +391,8 @@ err_srq_mtt:
        hns_roce_mtt_cleanup(hr_dev, &srq->mtt);
 
 err_buf:
-       if (udata)
-               ib_umem_release(srq->umem);
-       else
+       ib_umem_release(srq->umem);
+       if (!udata)
                hns_roce_buf_free(hr_dev, srq_buf_size, &srq->buf);
 
        return ret;
@@ -408,15 +406,15 @@ void hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
        hns_roce_srq_free(hr_dev, srq);
        hns_roce_mtt_cleanup(hr_dev, &srq->mtt);
 
-       if (ibsrq->uobject) {
+       if (udata) {
                hns_roce_mtt_cleanup(hr_dev, &srq->idx_que.mtt);
-               ib_umem_release(srq->idx_que.umem);
-               ib_umem_release(srq->umem);
        } else {
                kvfree(srq->wrid);
                hns_roce_buf_free(hr_dev, srq->max << srq->wqe_shift,
                                  &srq->buf);
        }
+       ib_umem_release(srq->idx_que.umem);
+       ib_umem_release(srq->umem);
 }
 
 int hns_roce_init_srq_table(struct hns_roce_dev *hr_dev)
index 3100b0c31b0af5c1a6e27e12b6b975eb2bcbac79..3c0c6aabc64e1c9ace0e341773c2e4046daf83b2 100644 (file)
@@ -2004,8 +2004,7 @@ static int i40iw_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata)
        struct cqp_commands_info *cqp_info;
        u32 stag_idx;
 
-       if (iwmr->region)
-               ib_umem_release(iwmr->region);
+       ib_umem_release(iwmr->region);
 
        if (iwmr->type != IW_MEMREG_TYPE_MEM) {
                /* region is released. only test for userness. */
index 72f238ddafb5e39067cfc44266daf912f4b6562f..a7d238d312f06ed8664456f8e8886b36d2ff8a8b 100644 (file)
@@ -277,9 +277,8 @@ err_dbmap:
 err_mtt:
        mlx4_mtt_cleanup(dev->dev, &cq->buf.mtt);
 
-       if (udata)
-               ib_umem_release(cq->umem);
-       else
+       ib_umem_release(cq->umem);
+       if (!udata)
                mlx4_ib_free_cq_buf(dev, &cq->buf, cq->ibcq.cqe);
 
 err_db:
@@ -468,11 +467,8 @@ err_buf:
        kfree(cq->resize_buf);
        cq->resize_buf = NULL;
 
-       if (cq->resize_umem) {
-               ib_umem_release(cq->resize_umem);
-               cq->resize_umem = NULL;
-       }
-
+       ib_umem_release(cq->resize_umem);
+       cq->resize_umem = NULL;
 out:
        mutex_unlock(&cq->resize_mutex);
 
@@ -494,11 +490,11 @@ void mlx4_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata)
                                struct mlx4_ib_ucontext,
                                ibucontext),
                        &mcq->db);
-               ib_umem_release(mcq->umem);
        } else {
                mlx4_ib_free_cq_buf(dev, &mcq->buf, cq->cqe);
                mlx4_db_free(dev->dev, &mcq->db);
        }
+       ib_umem_release(mcq->umem);
 }
 
 static void dump_cqe(void *cqe)
index 520364defa28ddda7256357bd81899fa29097165..82aff2f2fdc23b1b9615c910a29a80e707db3cc1 100644 (file)
@@ -1207,10 +1207,9 @@ err_mtt:
        mlx4_mtt_cleanup(dev->dev, &qp->mtt);
 
 err_buf:
-       if (qp->umem)
-               ib_umem_release(qp->umem);
-       else
+       if (!qp->umem)
                mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf);
+       ib_umem_release(qp->umem);
 
 err_db:
        if (!udata && qp_has_rq(init_attr))
@@ -1421,7 +1420,6 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
 
                        mlx4_ib_db_unmap_user(mcontext, &qp->db);
                }
-               ib_umem_release(qp->umem);
        } else {
                kvfree(qp->sq.wrid);
                kvfree(qp->rq.wrid);
@@ -1432,6 +1430,7 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
                if (qp->rq.wqe_cnt)
                        mlx4_db_free(dev->dev, &qp->db);
        }
+       ib_umem_release(qp->umem);
 
        del_gid_entries(qp);
 }
index c9f555e04c9f3fd8d1170568f2f03703545e2a91..848db7264cc9548f0eb1e02c10e29a04732806ca 100644 (file)
@@ -204,10 +204,9 @@ err_mtt:
        mlx4_mtt_cleanup(dev->dev, &srq->mtt);
 
 err_buf:
-       if (srq->umem)
-               ib_umem_release(srq->umem);
-       else
+       if (!srq->umem)
                mlx4_buf_free(dev->dev, buf_size, &srq->buf);
+       ib_umem_release(srq->umem);
 
 err_db:
        if (!udata)
@@ -275,13 +274,13 @@ void mlx4_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata)
                                struct mlx4_ib_ucontext,
                                ibucontext),
                        &msrq->db);
-               ib_umem_release(msrq->umem);
        } else {
                kvfree(msrq->wrid);
                mlx4_buf_free(dev->dev, msrq->msrq.max << msrq->msrq.wqe_shift,
                              &msrq->buf);
                mlx4_db_free(dev->dev, &msrq->db);
        }
+       ib_umem_release(msrq->umem);
 }
 
 void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index)
index 07b73df0e1a3564b7da73e2a26c060d27254fd9a..22230fd7d741a7524e6a8bb7e82fa8865d066c04 100644 (file)
@@ -1125,11 +1125,6 @@ static int resize_user(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
        return 0;
 }
 
-static void un_resize_user(struct mlx5_ib_cq *cq)
-{
-       ib_umem_release(cq->resize_umem);
-}
-
 static int resize_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
                         int entries, int cqe_size)
 {
@@ -1152,12 +1147,6 @@ ex:
        return err;
 }
 
-static void un_resize_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq)
-{
-       free_cq_buf(dev, cq->resize_buf);
-       cq->resize_buf = NULL;
-}
-
 static int copy_resize_cqes(struct mlx5_ib_cq *cq)
 {
        struct mlx5_ib_dev *dev = to_mdev(cq->ibcq.device);
@@ -1338,10 +1327,11 @@ ex_alloc:
        kvfree(in);
 
 ex_resize:
-       if (udata)
-               un_resize_user(cq);
-       else
-               un_resize_kernel(dev, cq);
+       ib_umem_release(cq->resize_umem);
+       if (!udata) {
+               free_cq_buf(dev, cq->resize_buf);
+               cq->resize_buf = NULL;
+       }
 ex:
        mutex_unlock(&cq->resize_mutex);
        return err;
index 4d033796dcfcc29299e59f6e1342e67f5ce1f0d2..994abcebb057670d84da78e34499dc00c354217c 100644 (file)
@@ -1507,10 +1507,9 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
        return 0;
 
 err:
-       if (mr->umem) {
-               ib_umem_release(mr->umem);
-               mr->umem = NULL;
-       }
+       ib_umem_release(mr->umem);
+       mr->umem = NULL;
+
        clean_mr(dev, mr);
        return err;
 }
@@ -1630,10 +1629,10 @@ static void dereg_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
         * remove the DMA mapping.
         */
        mlx5_mr_cache_free(dev, mr);
-       if (umem) {
-               ib_umem_release(umem);
+       ib_umem_release(umem);
+       if (umem)
                atomic_sub(npages, &dev->mdev->priv.reg_pages);
-       }
+
        if (!mr->allocated_from_cache)
                kfree(mr);
 }
index ae847709b3d3bdd80fe44d85ad9845b4c48574cd..12ccbd584d2ae45759020f04668bb71e2e7aa37e 100644 (file)
@@ -790,8 +790,7 @@ static void destroy_user_rq(struct mlx5_ib_dev *dev, struct ib_pd *pd,
                atomic_dec(&dev->delay_drop.rqs_cnt);
 
        mlx5_ib_db_unmap_user(context, &rwq->db);
-       if (rwq->umem)
-               ib_umem_release(rwq->umem);
+       ib_umem_release(rwq->umem);
 }
 
 static int create_user_rq(struct mlx5_ib_dev *dev, struct ib_pd *pd,
@@ -977,8 +976,7 @@ err_free:
        kvfree(*in);
 
 err_umem:
-       if (ubuffer->umem)
-               ib_umem_release(ubuffer->umem);
+       ib_umem_release(ubuffer->umem);
 
 err_bfreg:
        if (bfregn != MLX5_IB_INVALID_BFREG)
@@ -997,8 +995,7 @@ static void destroy_qp_user(struct mlx5_ib_dev *dev, struct ib_pd *pd,
                        ibucontext);
 
        mlx5_ib_db_unmap_user(context, &qp->db);
-       if (base->ubuffer.umem)
-               ib_umem_release(base->ubuffer.umem);
+       ib_umem_release(base->ubuffer.umem);
 
        /*
         * Free only the BFREGs which are handled by the kernel.
index d97124bee703d74a914e08afefb5882ad9a09dd6..23554d8bf2419441c63b5c2b062bd069225e42b8 100644 (file)
@@ -953,8 +953,7 @@ static int mthca_dereg_mr(struct ib_mr *mr, struct ib_udata *udata)
        struct mthca_mr *mmr = to_mmr(mr);
 
        mthca_free_mr(to_mdev(mr->device), mmr);
-       if (mmr->umem)
-               ib_umem_release(mmr->umem);
+       ib_umem_release(mmr->umem);
        kfree(mmr);
 
        return 0;
index 10b35edb286b99b19e1ac1748301a671f4c07c51..bccc1137810924780a60dedc100a784edac45a9a 100644 (file)
@@ -925,8 +925,7 @@ int ocrdma_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata)
        ocrdma_free_mr_pbl_tbl(dev, &mr->hwmr);
 
        /* it could be user registered memory. */
-       if (mr->umem)
-               ib_umem_release(mr->umem);
+       ib_umem_release(mr->umem);
        kfree(mr);
 
        /* Don't stop cleanup, in case FW is unresponsive */
index 3fc7a4e901c37f7cce0e04e84ca9392df1f40b76..27d90a84ea01c9b8d4b9b0c96ef47a390a8cd6ea 100644 (file)
@@ -1572,12 +1572,10 @@ qedr_iwarp_populate_user_qp(struct qedr_dev *dev,
 
 static void qedr_cleanup_user(struct qedr_dev *dev, struct qedr_qp *qp)
 {
-       if (qp->usq.umem)
-               ib_umem_release(qp->usq.umem);
+       ib_umem_release(qp->usq.umem);
        qp->usq.umem = NULL;
 
-       if (qp->urq.umem)
-               ib_umem_release(qp->urq.umem);
+       ib_umem_release(qp->urq.umem);
        qp->urq.umem = NULL;
 }
 
@@ -2680,8 +2678,7 @@ int qedr_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata)
                qedr_free_pbl(dev, &mr->info.pbl_info, mr->info.pbl_table);
 
        /* it could be user registered memory. */
-       if (mr->umem)
-               ib_umem_release(mr->umem);
+       ib_umem_release(mr->umem);
 
        kfree(mr);
 
index 38573fc0a9bf7dfeb232f3d92f0a326cd42f88b1..7800e6930502de7da27e9cf7207fce03a2825125 100644 (file)
@@ -213,8 +213,7 @@ int pvrdma_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
 err_page_dir:
        pvrdma_page_dir_cleanup(dev, &cq->pdir);
 err_umem:
-       if (!cq->is_kernel)
-               ib_umem_release(cq->umem);
+       ib_umem_release(cq->umem);
 err_cq:
        atomic_dec(&dev->num_cqs);
        return ret;
@@ -226,8 +225,7 @@ static void pvrdma_free_cq(struct pvrdma_dev *dev, struct pvrdma_cq *cq)
                complete(&cq->free);
        wait_for_completion(&cq->free);
 
-       if (!cq->is_kernel)
-               ib_umem_release(cq->umem);
+       ib_umem_release(cq->umem);
 
        pvrdma_page_dir_cleanup(dev, &cq->pdir);
 }
index 65dc47ffb8f329fb75e9587667df99bd2c782c39..f3a3d22ee8d7343bd634f4c8cc60c36e7410c456 100644 (file)
@@ -290,8 +290,7 @@ int pvrdma_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
                         "could not deregister mem region, error: %d\n", ret);
 
        pvrdma_page_dir_cleanup(dev, &mr->pdir);
-       if (mr->umem)
-               ib_umem_release(mr->umem);
+       ib_umem_release(mr->umem);
 
        kfree(mr->pages);
        kfree(mr);
index 0eaaead5baecbcdb7ebcad9650e484deb10a117b..bca6a58a442e1d2869e9bcc88c91d60380e7e518 100644 (file)
@@ -391,12 +391,8 @@ struct ib_qp *pvrdma_create_qp(struct ib_pd *pd,
 err_pdir:
        pvrdma_page_dir_cleanup(dev, &qp->pdir);
 err_umem:
-       if (!qp->is_kernel) {
-               if (qp->rumem)
-                       ib_umem_release(qp->rumem);
-               if (qp->sumem)
-                       ib_umem_release(qp->sumem);
-       }
+       ib_umem_release(qp->rumem);
+       ib_umem_release(qp->sumem);
 err_qp:
        kfree(qp);
        atomic_dec(&dev->num_qps);
@@ -429,12 +425,8 @@ static void pvrdma_free_qp(struct pvrdma_qp *qp)
                complete(&qp->free);
        wait_for_completion(&qp->free);
 
-       if (!qp->is_kernel) {
-               if (qp->rumem)
-                       ib_umem_release(qp->rumem);
-               if (qp->sumem)
-                       ib_umem_release(qp->sumem);
-       }
+       ib_umem_release(qp->rumem);
+       ib_umem_release(qp->sumem);
 
        pvrdma_page_dir_cleanup(dev, &qp->pdir);
 
index 54f3f9c27552776229fc0d8f7896f6f766605390..db800eb2b1f5c81ac433a5dace4dd692756f64ae 100644 (file)
@@ -560,8 +560,7 @@ int rvt_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
        if (ret)
                goto out;
        rvt_deinit_mregion(&mr->mr);
-       if (mr->umem)
-               ib_umem_release(mr->umem);
+       ib_umem_release(mr->umem);
        kfree(mr);
 out:
        return ret;
index f501f72489d84fba5ad881d862fa5fb1e0ab7d93..ea6a819b716750869087c82f56fe86467579a2dd 100644 (file)
@@ -96,8 +96,7 @@ void rxe_mem_cleanup(struct rxe_pool_entry *arg)
        struct rxe_mem *mem = container_of(arg, typeof(*mem), pelem);
        int i;
 
-       if (mem->umem)
-               ib_umem_release(mem->umem);
+       ib_umem_release(mem->umem);
 
        if (mem->map) {
                for (i = 0; i < mem->num_map; i++)