[Mesa-dev] [PATCH 04/10] gbm: handle queryImage() failure for GBM_BO_IMPORT_EGL_IMAGE
Eric Engestrom
eric.engestrom at imgtec.com
Tue Oct 17 10:09:35 UTC 2017
On Monday, 2017-10-16 16:04:06 +0000, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
>
> The function can fail. Check and teardown accordingly.
>
> Fixes: a43d286ef7f ("gbm: Add import from fd")
> Cc: Kristian Høgsberg <krh at bitplanet.net>
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
> src/gbm/backends/dri/gbm_dri.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
> index 4a51bd39903..9c9066e6661 100644
> --- a/src/gbm/backends/dri/gbm_dri.c
> +++ b/src/gbm/backends/dri/gbm_dri.c
> @@ -891,6 +891,7 @@ gbm_dri_bo_import(struct gbm_device *gbm,
> __DRIimage *image;
> unsigned dri_use = 0;
> int gbm_format;
> + unsigned query; /* EGLBoolean, but we cannot include the header */
`bool`? <stdbool.h> is already included.
>
> /* Required for query image WIDTH & HEIGHT */
> if (dri->image == NULL || dri->image->base.version < 4) {
> @@ -934,7 +935,12 @@ gbm_dri_bo_import(struct gbm_device *gbm,
>
> image = dri->lookup_image(dri->screen, buffer, dri->lookup_user_data);
> image = dri->image->dupImage(image, NULL);
> - dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_FORMAT, &dri_format);
> + query = dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_FORMAT, &dri_format);
> + if (!query) {
> + errno = EINVAL;
> + dri->image->destroyImage(image);
> + break;
> + }
> gbm_format = gbm_dri_to_gbm_format(dri_format);
> if (gbm_format == 0) {
> errno = EINVAL;
> --
> 2.14.1
>
More information about the mesa-dev
mailing list