From: Xianzhong Date: Mon, 28 Oct 2019 17:55:53 +0000 (+0800) Subject: MGS-5284 [#imx-1786] fix GPU panic with vm_mmap failure X-Git-Tag: rel_imx_4.19.35_1.1.0~3 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=bf4a45c5e62f500b0689cfd7312903444e932218;p=linux.git 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) --- 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); }