driver inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/10043 ---------------------------------------------------------------------- During allocating cache lock, if cache lock on hardware succeeds, but remapping the memory to userspace failed, current implementation does not release the hardware reserved, which could cause resource leakage. Fix this by add a exit path for the failure of remap_pfn_range. Fixes: c4e09ac64bc7 ("soc cache: support L3 cache lock in framework") Signed-off-by: Yushan Wang <wangyushan12@huawei.com> Signed-off-by: Hongye Lin <linhongye@h-partners.com> --- drivers/soc/hisilicon/hisi_soc_cache_framework.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/soc/hisilicon/hisi_soc_cache_framework.c b/drivers/soc/hisilicon/hisi_soc_cache_framework.c index c2dc8062ff86..0d6ba0333df1 100644 --- a/drivers/soc/hisilicon/hisi_soc_cache_framework.c +++ b/drivers/soc/hisilicon/hisi_soc_cache_framework.c @@ -311,7 +311,7 @@ static int hisi_soc_cache_mmap(struct file *file, struct vm_area_struct *vma) hisi_soc_cache_vm_open(vma); if (clr->status) { ret = clr->status; - goto out_page; + goto out_open; } ret = remap_pfn_range(vma, vma->vm_start, PFN_DOWN(addr), size, @@ -325,7 +325,8 @@ static int hisi_soc_cache_mmap(struct file *file, struct vm_area_struct *vma) return 0; out_page: - + hisi_soc_cache_unlock(clr->cpu, clr->addr); +out_open: free_contig_range(PHYS_PFN(clr->addr), 1 << order); return ret; } -- 2.33.0