gbm: return appropriate error when queryImage() fails

Change gbm_dri_bo_get_fd to check the return value of queryImage and
return -1 (an invalid file descriptor) if an error occurs.

Update the comment for gbm_bo_get_fd to return -1, since (apart from the
above) we've already return -1 on error.

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>

(cherry picked from commit 2d05ba2ca0)
This commit is contained in:
Nicholas Bishop 2016-09-08 15:55:02 -04:00 committed by Emil Velikov
parent 48f001b836
commit 29320aa06a
2 changed files with 4 additions and 2 deletions

View file

@ -589,7 +589,8 @@ gbm_dri_bo_get_fd(struct gbm_bo *_bo)
if (bo->image == NULL)
return -1;
dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_FD, &fd);
if (!dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_FD, &fd))
return -1;
return fd;
}

View file

@ -242,7 +242,8 @@ gbm_bo_get_handle(struct gbm_bo *bo)
* descriptor.
* \param bo The buffer object
* \return Returns a file descriptor referring to the underlying buffer
* \return Returns a file descriptor referring to the underlying buffer or -1
* if an error occurs.
*/
GBM_EXPORT int
gbm_bo_get_fd(struct gbm_bo *bo)