st/dri: check pipe_screen->resource_get_handle() return value
authorNicholas Bishop <nbishop@neverware.com>
Thu, 22 Sep 2016 15:04:13 +0000 (16:04 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Tue, 27 Sep 2016 12:37:21 +0000 (13:37 +0100)
Change dri2_query_image to check the return value of resource_get_handle
and return GL_FALSE if an error occurs.

For reference this is an example callstack that should propagate the
error back to the user:

    i915_drm_buffer_get_handle
    i915_texture_get_handle
    u_resource_get_handle_vtbl
    dri2_query_image
    gbm_dri_bo_get_fd
    gbm_bo_get_fd

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Nicholas Bishop <nbishop@neverware.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> (v1)
[Emil Velikov: Split from larger patch, polish coding style, cc stable]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
src/gallium/state_trackers/dri/dri2.c

index a22e7ee6ace7d0fec618c23f35fb19bc4bef25bc..64d9c3ed4080d3e2b4dabbd4f3eff1d265b656c0 100644 (file)
@@ -1055,8 +1055,10 @@ dri2_query_image(__DRIimage *image, int attrib, int *value)
       return GL_TRUE;
    case __DRI_IMAGE_ATTRIB_FD:
       whandle.type= DRM_API_HANDLE_TYPE_FD;
-      image->texture->screen->resource_get_handle(image->texture->screen,
-         NULL, image->texture, &whandle, usage);
+      if (!image->texture->screen->resource_get_handle(image->texture->screen,
+            NULL, image->texture, &whandle, usage))
+         return GL_FALSE;
+
       *value = whandle.handle;
       return GL_TRUE;
    case __DRI_IMAGE_ATTRIB_FORMAT: