From: Chuanbo Weng Date: Tue, 6 Sep 2016 09:28:43 +0000 (+0800) Subject: gbm: fix potential NULL deref of mapImage/unmapImage. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9a1eb5423722955bee5c5b5f48fb058f0884fab0;p=mesa.git 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: Signed-off-by: Chuanbo Weng Reviewed-by: Emil Velikov --- diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index c1f9d62d366..0ab67dad210 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);