This is a note to let you know that I've just added the patch titled RDMA/hns: Fix refcount leak in hns_roce_mmap to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: rdma-hns-fix-refcount-leak-in-hns_roce_mmap.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 7a0e41b9c3f3e798d17d28a745783d68cf944031 Author: Miaoqian Lin <linmq006@xxxxxxxxx> Date: Fri Dec 23 11:29:00 2022 +0400 RDMA/hns: Fix refcount leak in hns_roce_mmap [ Upstream commit cf6a05c8494a8ae7fec8e5f1229b45ca5b4bcd30 ] rdma_user_mmap_entry_get_pgoff() takes the reference. Add missing rdma_user_mmap_entry_put() to release the reference. Fixes: 0045e0d3f42e ("RDMA/hns: Support direct wqe of userspace") Signed-off-by: Miaoqian Lin <linmq006@xxxxxxxxx> Acked-by Haoyue Xu <xuhaoyue1@xxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20221223072900.802728-1-linmq006@xxxxxxxxx Signed-off-by: Leon Romanovsky <leon@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index 8ba68ac12388d..946ba1109e878 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -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; }