OSDN Git Service

RDMA/qedr: Fix memory leak in user qp and mr
authorMichal Kalderon <michal.kalderon@marvell.com>
Sun, 27 Oct 2019 20:04:51 +0000 (22:04 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Mon, 28 Oct 2019 17:01:36 +0000 (14:01 -0300)
User QPs pbl's weren't freed properly.
MR pbls weren't freed properly.

Fixes: e0290cce6ac0 ("qedr: Add support for memory registeration verbs")
Link: https://lore.kernel.org/r/20191027200451.28187-5-michal.kalderon@marvell.com
Signed-off-by: Ariel Elior <ariel.elior@marvell.com>
Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/hw/qedr/verbs.c

index a17b388..8b4240c 100644 (file)
@@ -1581,6 +1581,14 @@ static void qedr_cleanup_user(struct qedr_dev *dev, struct qedr_qp *qp)
 
        ib_umem_release(qp->urq.umem);
        qp->urq.umem = NULL;
+
+       if (rdma_protocol_roce(&dev->ibdev, 1)) {
+               qedr_free_pbl(dev, &qp->usq.pbl_info, qp->usq.pbl_tbl);
+               qedr_free_pbl(dev, &qp->urq.pbl_info, qp->urq.pbl_tbl);
+       } else {
+               kfree(qp->usq.pbl_tbl);
+               kfree(qp->urq.pbl_tbl);
+       }
 }
 
 static int qedr_create_user_qp(struct qedr_dev *dev,
@@ -2689,8 +2697,8 @@ int qedr_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata)
 
        dev->ops->rdma_free_tid(dev->rdma_ctx, mr->hw_mr.itid);
 
-       if ((mr->type != QEDR_MR_DMA) && (mr->type != QEDR_MR_FRMR))
-               qedr_free_pbl(dev, &mr->info.pbl_info, mr->info.pbl_table);
+       if (mr->type != QEDR_MR_DMA)
+               free_mr_info(dev, &mr->info);
 
        /* it could be user registered memory. */
        ib_umem_release(mr->umem);