| From a115aa00b18f7b8982b8f458149632caf64a862a Mon Sep 17 00:00:00 2001 |
| From: Zhengchao Shao <shaozhengchao@huawei.com> |
| Date: Sat, 19 Nov 2022 15:08:34 +0800 |
| Subject: [PATCH 1/1] RDMA/hns: fix memory leak in hns_roce_alloc_mr() |
| Git-commit: a115aa00b18f7b8982b8f458149632caf64a862a |
| Patch-mainline: v6.2-rc1 |
| References: git-fixes |
| |
| When hns_roce_mr_enable() failed in hns_roce_alloc_mr(), mr_key is not |
| released. Compiled test only. |
| |
| Fixes: 9b2cf76c9f05 ("RDMA/hns: Optimize PBL buffer allocation process") |
| Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com> |
| Link: https://lore.kernel.org/r/20221119070834.48502-1-shaozhengchao@huawei.com |
| Signed-off-by: Leon Romanovsky <leon@kernel.org> |
| Acked-by: Nicolas Morey <nmorey@suse.com> |
| |
| drivers/infiniband/hw/hns/hns_roce_mr.c | 4 ++-- |
| 1 file changed, 2 insertions(+), 2 deletions(-) |
| |
| diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c |
| index 845ac7d3831f..37a5cf62f88b 100644 |
| |
| |
| @@ -392,10 +392,10 @@ struct ib_mr *hns_roce_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type, |
| |
| return &mr->ibmr; |
| |
| -err_key: |
| - free_mr_key(hr_dev, mr); |
| err_pbl: |
| free_mr_pbl(hr_dev, mr); |
| +err_key: |
| + free_mr_key(hr_dev, mr); |
| err_free: |
| kfree(mr); |
| return ERR_PTR(ret); |
| -- |
| 2.38.0.1.gee35aeee4b76 |
| |