RDMA/hns: Fix PD memory leak for internal allocation [Linux 5.2]

RDMA/hns: Fix PD memory leak for internal allocation [Linux 5.2]

This Linux kernel change "RDMA/hns: Fix PD memory leak for internal allocation" is included in the Linux 5.2 release. This change is authored by Leon Romanovsky <leonro [at] mellanox.com> on Mon May 20 09:43:53 2019 +0300. The commit for this change in Linux stable tree is 619122b (patch).

RDMA/hns: Fix PD memory leak for internal allocation

free_pd is allocated internally by the driver hence needs to be freed
internally too or it leaks.

Fixes: 21a428a019c9 ("RDMA: Handle PD allocations by IB/core")
Signed-off-by: Leon Romanovsky <[email protected]>
Acked-by: Lijun Ou <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>

There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index 4c5d0f1..e068a02 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -899,6 +899,7 @@ static void hns_roce_v1_release_lp_qp(struct hns_roce_dev *hr_dev)
        dev_err(dev, "Destroy cq for mr_free failed(%d)!\n", ret);

    hns_roce_dealloc_pd(&free_mr->mr_free_pd->ibpd, NULL);
+   kfree(&free_mr->mr_free_pd->ibpd);
 }

 static int hns_roce_db_init(struct hns_roce_dev *hr_dev)

Leave a Reply

Your email address will not be published. Required fields are marked *