RDMA/hns: Fix refcount leak in hns_roce_mmap
Subsystems (2)
PATCH v2 1/1 RDMA/hns: Fix refcount leak in hns_roce_mmap
rdma_user_mmap_entry_get_pgoff() takes the reference. Add missing rdma_user_mmap_entry_put() to release the reference.
---
change in v2:
- use goto label to manage the release.
--- drivers/infiniband/hw/hns/hns_roce_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_main.c +3 -2
@@ -443,14 +443,15 @@ static int hns_roce_mmap(struct ib_ucontext *uctx, struct vm_area_struct *vma) prot =pgprot_device (vma->vm_page_prot);break ;default : -return -EINVAL ; + ret = -EINVAL ; + goto out; } ret =rdma_user_mmap_io (uctx, vma, pfn, rdma_entry->npages *PAGE_SIZE , prot, rdma_entry); +out:rdma_user_mmap_entry_put (rdma_entry); -return ret; }
Signature · 1 line
2.25.1
Quoted 25 lines · Miaoqian Lin
rdma_user_mmap_entry_get_pgoff()takes the reference. Add missingrdma_user_mmap_entry_put()to release the reference.Fixes 0045e0d3f42e ("RDMA/hns: Support direct wqe of userspace")Signed-off-by Miaoqian Lin <[email protected]>---
change in v2:
- use goto label to manage the release.--- drivers/infiniband/hw/hns/hns_roce_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/infiniband/hw/hns/hns_roce_main.c +2
-1@@ -443,14 +443,15 @@ static int hns_roce_mmap(struct ib_ucontext *uctx, struct vm_area_struct *vma) prot =pgprot_device (vma->vm_page_prot);break ;default : -return -EINVAL ; + ret = -EINVAL ; + goto out; }
drivers/infiniband/hw/hns/hns_roce_main.c static int hns_roce_mmap(struct ib_ucontext *uctx, struct vm_area_struct *vma) · line 457
Quoted 10 lines
drivers/infiniband/hw/hns/hns_roce_main.c +1
-1ret =rdma_user_mmap_io (uctx, vma, pfn, rdma_entry->npages *PAGE_SIZE , prot, rdma_entry); +out:rdma_user_mmap_entry_put (rdma_entry); -return ret; }
Thank you. For the patch:
Acked-by Haoyue Xu <[email protected]>
Regards,
Haoyue
Leon Romanovsky
AppliedQuoted 4 lines · Miaoqian Lin
rdma_user_mmap_entry_get_pgoff()takes the reference. Add missingrdma_user_mmap_entry_put()to release the reference.
Applied, thanks!
[1/1] RDMA/hns: Fix refcount leak in hns_roce_mmap
https://git.kernel.org/rdma/rdma/c/cf6a05c8494a8a
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>