MGS-5284 [#imx-1786] fix GPU panic with vm_mmap failure
authorXianzhong <xianzhong.li@nxp.com>
Mon, 28 Oct 2019 17:55:53 +0000 (01:55 +0800)
committerXianzhong <xianzhong.li@nxp.com>
Tue, 29 Oct 2019 15:31:55 +0000 (23:31 +0800)
When vm_mmap fail, code jump to OnError with error status and userLogical variable != 0.
Then _CMAFSLUnmapUser is called with a invalid virtual address (MdlMap->vmaAddr) and cause panic.

Check userLogical to avoid GPU kernel panic for error handling.

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

drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/freescale/gc_hal_kernel_allocator_cma.c

index b03c044..495ac34 100644 (file)
@@ -441,7 +441,7 @@ _CMAFSLMapUser(
     up_write(&current->mm->mmap_sem);
 
 OnError:
-    if (gcmIS_ERROR(status) && userLogical)
+    if (gcmIS_ERROR(status) && userLogical && !IS_ERR(userLogical))
     {
         _CMAFSLUnmapUser(Allocator, Mdl, userLogical, Mdl->numPages * PAGE_SIZE);
     }