Mesa (master): gbm: fix potential NULL deref of mapImage/unmapImage.

Emil Velikov evelikov at kemper.freedesktop.org
Mon Sep 12 15:53:15 UTC 2016


Module: Mesa
Branch: master
Commit: 9a1eb5423722955bee5c5b5f48fb058f0884fab0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9a1eb5423722955bee5c5b5f48fb058f0884fab0

Author: Chuanbo Weng <chuanbo.weng at intel.com>
Date:   Tue Sep  6 17:28:43 2016 +0800

gbm: fix potential NULL deref of mapImage/unmapImage.

The mapImage/unmapImage functions of DRIimage extension can be NULL,
so we should add additional check for them.

Cc: <mesa-stable at lists.freedesktop.org>
Signed-off-by: Chuanbo Weng <chuanbo.weng at intel.com>
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>

---

 src/gbm/backends/dri/gbm_dri.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index c1f9d62..0ab67da 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -949,7 +949,7 @@ gbm_dri_bo_map(struct gbm_bo *_bo,
       return *map_data;
    }
 
-   if (!dri->image || dri->image->base.version < 12) {
+   if (!dri->image || dri->image->base.version < 12 || !dri->image->mapImage) {
       errno = ENOSYS;
       return NULL;
    }
@@ -980,7 +980,8 @@ gbm_dri_bo_unmap(struct gbm_bo *_bo, void *map_data)
       return;
    }
 
-   if (!dri->context || !dri->image || dri->image->base.version < 12)
+   if (!dri->context || !dri->image ||
+       dri->image->base.version < 12 || !dri->image->unmapImage)
       return;
 
    dri->image->unmapImage(dri->context, bo->image, map_data);




More information about the mesa-commit mailing list