aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiaomeng Tong <[email protected]>2022-03-27 13:09:45 +0800
committerGerd Hoffmann <[email protected]>2022-06-09 07:30:12 +0200
commitbd63f11f4c3c46afec07d821f74736161ff6e526 (patch)
tree64b77fe2043994618dd2366a2eb7fef0a0eac253
parent6aed665f9d8368ae1e962f44339150884bb47f5b (diff)
virtio-gpu: fix a missing check to avoid NULL dereference
'cache_ent' could be set NULL inside virtio_gpu_cmd_get_capset() and it will lead to a NULL dereference by a lately use of it (i.e., ptr = cache_ent->caps_cache). Fix it with a NULL check. Fixes: 62fb7a5e10962 ("virtio-gpu: add 3d/virgl support") Signed-off-by: Xiaomeng Tong <[email protected]> Reviewed-by: Chia-I Wu <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected] [ kraxel: minor codestyle fixup ] Signed-off-by: Gerd Hoffmann <[email protected]>
-rw-r--r--drivers/gpu/drm/virtio/virtgpu_ioctl.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index f8d83358d2a0..9b2702116f93 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -580,8 +580,10 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev,
spin_unlock(&vgdev->display_info_lock);
/* not in cache - need to talk to hw */
- virtio_gpu_cmd_get_capset(vgdev, found_valid, args->cap_set_ver,
- &cache_ent);
+ ret = virtio_gpu_cmd_get_capset(vgdev, found_valid, args->cap_set_ver,
+ &cache_ent);
+ if (ret)
+ return ret;
virtio_gpu_notify(vgdev);
copy_exit: