fix rga1/rga2 mem leak when create mmu table use user malloc buf
authorzsq <zsq@rock-chips.com>
Sun, 6 Jul 2014 07:34:26 +0000 (15:34 +0800)
committerzsq <zsq@rock-chips.com>
Sun, 6 Jul 2014 07:34:26 +0000 (15:34 +0800)
drivers/video/rockchip/rga/rga_mmu_info.c
drivers/video/rockchip/rga2/rga2_mmu_info.c

index de1a60ee034fd8ae41c718e1b790668a904cb453..86e8205fbb8300c4ef27fd6f96c6d1d19717ea9d 100755 (executable)
@@ -284,6 +284,13 @@ static int rga_MapUserMemory(struct page **pages,
         {\r
             struct vm_area_struct *vma;\r
 \r
+            if (result>0) {\r
+                           down_read(&current->mm->mmap_sem);\r
+                           for (i = 0; i < result; i++)\r
+                                   put_page(pages[i]);\r
+                           up_read(&current->mm->mmap_sem);\r
+                   }\r
+\r
             for(i=0; i<pageCount; i++)\r
             {\r
                 vma = find_vma(current->mm, (Memory + i) << PAGE_SHIFT);\r
@@ -378,6 +385,11 @@ static int rga_MapUserMemory(struct page **pages,
             pageTable[i] = page_to_phys(pages[i]);\r
         }\r
 \r
+        down_read(&current->mm->mmap_sem);\r
+               for (i = 0; i < result; i++)\r
+                       put_page(pages[i]);\r
+               up_read(&current->mm->mmap_sem);\r
+\r
         return 0;\r
     }\r
     while(0);\r
index d90f58d67436610fc97ef04c82f1e70ecbda135c..b5c6af78cc6876de93eb38c4ce939c53e15b34bf 100644 (file)
@@ -294,6 +294,13 @@ static int rga2_MapUserMemory(struct page **pages,
         {\r
             struct vm_area_struct *vma;\r
 \r
+            if (result>0) {\r
+                           down_read(&current->mm->mmap_sem);\r
+                           for (i = 0; i < result; i++)\r
+                                   put_page(pages[i]);\r
+                           up_read(&current->mm->mmap_sem);\r
+                   }\r
+\r
             for(i=0; i<pageCount; i++)\r
             {\r
                 vma = find_vma(current->mm, (Memory + i) << PAGE_SHIFT);\r
@@ -388,6 +395,11 @@ static int rga2_MapUserMemory(struct page **pages,
             pageTable[i] = page_to_phys(pages[i]);\r
         }\r
 \r
+        down_read(&current->mm->mmap_sem);\r
+               for (i = 0; i < result; i++)\r
+                       put_page(pages[i]);\r
+               up_read(&current->mm->mmap_sem);\r
+\r
         return 0;\r
     }\r
     while(0);\r