frontends/va: check decoder in va surface call
authorBoyuan Zhang <boyuan.zhang@amd.com>
Thu, 23 Mar 2023 13:34:55 +0000 (09:34 -0400)
committerBoyuan Zhang <boyuan.zhang@amd.com>
Thu, 23 Mar 2023 14:14:14 +0000 (10:14 -0400)
Add a check to see if decoder is valid before using it. Currently we
only support decode and encode operations, return unsupported error
for all other entrypoints.

Signed-off-by: Boyuan Zhang <boyuan.zhang@amd.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21905>

src/gallium/frontends/va/surface.c

index 936fd31..21cf8ad 100644 (file)
@@ -132,6 +132,11 @@ vlVaSyncSurface(VADriverContextP ctx, VASurfaceID render_target)
       return VA_STATUS_ERROR_INVALID_CONTEXT;
    }
 
+   if (!context->decoder) {
+      mtx_unlock(&drv->mutex);
+      return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
+   }
+
    if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM) {
       int ret = 0;
 
@@ -212,6 +217,11 @@ vlVaQuerySurfaceStatus(VADriverContextP ctx, VASurfaceID render_target, VASurfac
       return VA_STATUS_ERROR_INVALID_CONTEXT;
    }
 
+   if (!context->decoder) {
+      mtx_unlock(&drv->mutex);
+      return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
+   }
+
    if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) {
       if(surf->feedback == NULL)
          *status=VASurfaceReady;