Skip to content

Commit 7cf6dd4

Browse files
committed
drm/virtio: Don't attach GEM to a non-created context in gem_object_open()
The vfpriv->ctx_id is always initialized to a non-zero value. Check whether context was created before attaching GEM to this context ID. This left unnoticed previously because host silently skips attachment if context doesn't exist, still we shouldn't do that for consistency. Fixes: 086b9f2 ("drm/virtio: Don't create a context with default param if context_init is supported") Cc: <[email protected]> # v6.14+ Signed-off-by: Dmitry Osipenko <[email protected]> Reviewed-by: Rob Clark <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d893da8 commit 7cf6dd4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/gpu/drm/virtio/virtgpu_gem.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,14 @@ int virtio_gpu_gem_object_open(struct drm_gem_object *obj,
115115
if (!vgdev->has_context_init)
116116
virtio_gpu_create_context(obj->dev, file);
117117

118-
objs = virtio_gpu_array_alloc(1);
119-
if (!objs)
120-
return -ENOMEM;
121-
virtio_gpu_array_add_obj(objs, obj);
118+
if (vfpriv->context_created) {
119+
objs = virtio_gpu_array_alloc(1);
120+
if (!objs)
121+
return -ENOMEM;
122+
virtio_gpu_array_add_obj(objs, obj);
122123

123-
if (vfpriv->ctx_id)
124124
virtio_gpu_cmd_context_attach_resource(vgdev, vfpriv->ctx_id, objs);
125+
}
125126

126127
out_notify:
127128
virtio_gpu_notify(vgdev);

0 commit comments

Comments
 (0)