From d061f9c4b7300017df3aaf5b3f11768fbe760669 Mon Sep 17 00:00:00 2001 From: zsq Date: Sun, 6 Jul 2014 15:34:26 +0800 Subject: [PATCH] fix rga1/rga2 mem leak when create mmu table use user malloc buf --- drivers/video/rockchip/rga/rga_mmu_info.c | 12 ++++++++++++ drivers/video/rockchip/rga2/rga2_mmu_info.c | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/video/rockchip/rga/rga_mmu_info.c b/drivers/video/rockchip/rga/rga_mmu_info.c index de1a60ee034f..86e8205fbb83 100755 --- a/drivers/video/rockchip/rga/rga_mmu_info.c +++ b/drivers/video/rockchip/rga/rga_mmu_info.c @@ -284,6 +284,13 @@ static int rga_MapUserMemory(struct page **pages, { struct vm_area_struct *vma; + if (result>0) { + down_read(¤t->mm->mmap_sem); + for (i = 0; i < result; i++) + put_page(pages[i]); + up_read(¤t->mm->mmap_sem); + } + for(i=0; imm, (Memory + i) << PAGE_SHIFT); @@ -378,6 +385,11 @@ static int rga_MapUserMemory(struct page **pages, pageTable[i] = page_to_phys(pages[i]); } + down_read(¤t->mm->mmap_sem); + for (i = 0; i < result; i++) + put_page(pages[i]); + up_read(¤t->mm->mmap_sem); + return 0; } while(0); diff --git a/drivers/video/rockchip/rga2/rga2_mmu_info.c b/drivers/video/rockchip/rga2/rga2_mmu_info.c index d90f58d67436..b5c6af78cc68 100644 --- a/drivers/video/rockchip/rga2/rga2_mmu_info.c +++ b/drivers/video/rockchip/rga2/rga2_mmu_info.c @@ -294,6 +294,13 @@ static int rga2_MapUserMemory(struct page **pages, { struct vm_area_struct *vma; + if (result>0) { + down_read(¤t->mm->mmap_sem); + for (i = 0; i < result; i++) + put_page(pages[i]); + up_read(¤t->mm->mmap_sem); + } + for(i=0; imm, (Memory + i) << PAGE_SHIFT); @@ -388,6 +395,11 @@ static int rga2_MapUserMemory(struct page **pages, pageTable[i] = page_to_phys(pages[i]); } + down_read(¤t->mm->mmap_sem); + for (i = 0; i < result; i++) + put_page(pages[i]); + up_read(¤t->mm->mmap_sem); + return 0; } while(0); -- 2.34.1