vrend_renderer: add NULL checks

This should fix the following fuzzer failures.

SCARINESS: 10 (null-deref)

v2: Merge various checks (@davidriley)

Reviewed-by: David Riley <davidriley@chromium.org>
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Gurchetan Singh 5 years ago
parent e36302cc93
commit ec371e55f8
  1. 7
      src/vrend_renderer.c

@ -691,7 +691,7 @@ static inline bool vrend_format_can_scanout(enum virgl_formats format)
{
#ifdef ENABLE_GBM_ALLOCATION
uint32_t gbm_format = virgl_gbm_convert_format(format);
if (!gbm_format)
if (!gbm || !gbm->device || !gbm_format)
return false;
return gbm_device_is_format_supported(gbm->device, gbm_format, GBM_BO_USE_SCANOUT);
@ -6153,10 +6153,7 @@ static void *vrend_allocate_using_gbm(struct vrend_resource *gr)
if (gr->base.depth0 != 1 || gr->base.last_level != 0 || gr->base.nr_samples != 0)
return NULL;
if (!gbm_format)
return NULL;
if (!gbm_flags)
if (!gbm || !gbm->device || !gbm_format || !gbm_flags)
return NULL;
if ((gr->base.bind & (VIRGL_RES_BIND_SCANOUT | VIRGL_RES_BIND_SHARED)) == 0)

Loading…
Cancel
Save