From 8f0d3874411ec3c0dcb1171cad5930db70fb48b4 Mon Sep 17 00:00:00 2001 From: Danylo Piliaiev Date: Tue, 28 Apr 2020 14:51:26 +0300 Subject: [PATCH] iris/bufmgr: Check if iris_bo_gem_mmap failed After refactoring of iris_bo_map_cpu and iris_bo_map_wc - immediate return of NULL on failure to mmap a buffer was lost. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2855 Fixes: 5bc3f52dd8c2b5acaae959ccae2e1fb7c769bb22 Signed-off-by: Danylo Piliaiev Reviewed-by: Lionel Landwerlin Part-of: --- src/gallium/drivers/iris/iris_bufmgr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index 5bf52b32eeb..c8e6d0c654b 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -980,6 +980,10 @@ iris_bo_map_cpu(struct pipe_debug_callback *dbg, if (!bo->map_cpu) { DBG("iris_bo_map_cpu: %d (%s)\n", bo->gem_handle, bo->name); void *map = iris_bo_gem_mmap(dbg, bo, false); + if (!map) { + return NULL; + } + VG_DEFINED(map, bo->size); if (p_atomic_cmpxchg(&bo->map_cpu, NULL, map)) { @@ -1027,6 +1031,10 @@ iris_bo_map_wc(struct pipe_debug_callback *dbg, if (!bo->map_wc) { DBG("iris_bo_map_wc: %d (%s)\n", bo->gem_handle, bo->name); void *map = iris_bo_gem_mmap(dbg, bo, true); + if (!map) { + return NULL; + } + VG_DEFINED(map, bo->size); if (p_atomic_cmpxchg(&bo->map_wc, NULL, map)) { -- 2.30.2