From bf4a45c5e62f500b0689cfd7312903444e932218 Mon Sep 17 00:00:00 2001 From: Xianzhong Date: Tue, 29 Oct 2019 01:55:53 +0800 Subject: [PATCH] MGS-5284 [#imx-1786] fix GPU panic with vm_mmap failure 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 (cherry picked from commit 710bbfc815c1058d32ad2295d630efb238ef1beb) --- .../kernel/allocator/freescale/gc_hal_kernel_allocator_cma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/freescale/gc_hal_kernel_allocator_cma.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/freescale/gc_hal_kernel_allocator_cma.c index b03c0444fbe8..495ac34a5114 100644 --- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/freescale/gc_hal_kernel_allocator_cma.c +++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/freescale/gc_hal_kernel_allocator_cma.c @@ -441,7 +441,7 @@ _CMAFSLMapUser( up_write(¤t->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); } -- 2.17.1