virgl: create or import blob must fail on duplicate resource id

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
macos/master
Yiwei Zhang 3 years ago
parent 9f4e730bcf
commit 728effff74
  1. 8
      src/virglrenderer.c

@ -884,6 +884,10 @@ int virgl_renderer_resource_create_blob(const struct virgl_renderer_resource_cre
if (args->res_handle == 0) if (args->res_handle == 0)
return -EINVAL; return -EINVAL;
/* user resource id must be unique */
if (virgl_resource_lookup(args->res_handle))
return -EINVAL;
if (args->size == 0) if (args->size == 0)
return -EINVAL; return -EINVAL;
if (has_guest_storage) { if (has_guest_storage) {
@ -1042,6 +1046,10 @@ virgl_renderer_resource_import_blob(const struct virgl_renderer_resource_import_
if (args->res_handle == 0) if (args->res_handle == 0)
return -EINVAL; return -EINVAL;
/* user resource id must be unique */
if (virgl_resource_lookup(args->res_handle))
return -EINVAL;
switch (args->blob_mem) { switch (args->blob_mem) {
case VIRGL_RENDERER_BLOB_MEM_HOST3D: case VIRGL_RENDERER_BLOB_MEM_HOST3D:
case VIRGL_RENDERER_BLOB_MEM_GUEST_VRAM: case VIRGL_RENDERER_BLOB_MEM_GUEST_VRAM:

Loading…
Cancel
Save