MGS-5176 [#imx-1744] Coveriy - need free the pages if malloc memory failed
authorElla Feng <ella.feng@nxp.com>
Thu, 24 Oct 2019 15:10:15 +0000 (23:10 +0800)
committerXianzhong <xianzhong.li@nxp.com>
Tue, 29 Oct 2019 15:31:21 +0000 (23:31 +0800)
When alloc NonContiguous1MPages, if malloc fail, need free the pages to avoid memory leak

Signed-off-by: Xianzhong Li <xianzhong.li@nxp.com>
(cherry picked from commit 30b05a615613a7e47db5e98dddb0fae9ca42b924)

drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_gfp.c

index b157252..059512a 100644 (file)
@@ -424,6 +424,7 @@ _NonContiguous1MPagesAlloc(
 
             if (order >= MAX_ORDER)
             {
+                kfree(pages);
                 _NonContiguous1MPagesFree(MdlPriv, MdlPriv->numPages1M);
                 return gcvNULL;
             }
@@ -433,6 +434,7 @@ _NonContiguous1MPagesAlloc(
 
         if (MdlPriv->Pages1M[i] == gcvNULL)
         {
+            kfree(pages);
             _NonContiguous1MPagesFree(MdlPriv, MdlPriv->numPages1M);
             return gcvNULL;
         }