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)
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);
}