From: zsq Date: Sun, 6 Jul 2014 07:34:26 +0000 (+0800) Subject: fix rga1/rga2 mem leak when create mmu table use user malloc buf X-Git-Tag: firefly_0821_release~4996 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d061f9c4b7300017df3aaf5b3f11768fbe760669;p=firefly-linux-kernel-4.4.55.git fix rga1/rga2 mem leak when create mmu table use user malloc buf --- 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);