[Mesa-dev] [PATCH] egl: don't NULL deref the .get_capabilities function pointer

Tapani Pälli tapani.palli at intel.com
Tue Aug 15 11:11:47 UTC 2017


seems rare scenario indeed but there's similar check for image extension 
caps;

Reviewed-by: Tapani Pälli <tapani.palli at intel.com>

On 08/07/2017 07:23 PM, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
> 
> One could easily introduce version 3 of the DRI2fenceExtension,
> extending the struct, while not implementing the above function.
> 
> Thus we'll end up with NULL pointer, and dereferencing it won't fare
> too well.
> 
> Fixes: 0201f01dc4e ("egl: add EGL_ANDROID_native_fence_sync")
> Cc: Rob Clark <robclark at freedesktop.org>
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
> Yes the scenario doesn't happen too often ;-)
> ---
>   src/egl/drivers/dri2/egl_dri2.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index 936b7c5199e..69d1f8d258f 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -676,7 +676,8 @@ dri2_setup_screen(_EGLDisplay *disp)
>         disp->Extensions.KHR_wait_sync = EGL_TRUE;
>         if (dri2_dpy->fence->get_fence_from_cl_event)
>            disp->Extensions.KHR_cl_event2 = EGL_TRUE;
> -      if (dri2_dpy->fence->base.version >= 2) {
> +      if (dri2_dpy->fence->base.version >= 2 &&
> +          dri2_dpy->fence->get_capabilities) {
>            unsigned capabilities =
>               dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen);
>            disp->Extensions.ANDROID_native_fence_sync =
> 


More information about the mesa-dev mailing list