diff options
author | Vivek Kasireddy <[email protected]> | 2021-11-04 14:42:49 -0700 |
---|---|---|
committer | Gerd Hoffmann <[email protected]> | 2021-11-08 13:54:41 +0100 |
commit | d89c0c8322ecdc9a2ec84b959b6f766be082da76 (patch) | |
tree | 4da172380ebb993989de676f8f80dc7ab0feeac7 | |
parent | 14d9a37c952588930d7226953359fea3ab956d39 (diff) |
drm/virtio: Fix NULL dereference error in virtio_gpu_poll
When virgl is not enabled, vfpriv pointer would not be allocated.
Therefore, check for a valid value before dereferencing.
Reported-by: Christian Zigotzky <[email protected]>
Cc: Gurchetan Singh <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Signed-off-by: Vivek Kasireddy <[email protected]>
Tested-by: Christian Zigotzky <[email protected]>
Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
-rw-r--r-- | drivers/gpu/drm/virtio/virtgpu_drv.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c index 749db18dcfa2..d86e1ad4a972 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.c +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c @@ -163,10 +163,11 @@ static __poll_t virtio_gpu_poll(struct file *filp, struct drm_file *drm_file = filp->private_data; struct virtio_gpu_fpriv *vfpriv = drm_file->driver_priv; struct drm_device *dev = drm_file->minor->dev; + struct virtio_gpu_device *vgdev = dev->dev_private; struct drm_pending_event *e = NULL; __poll_t mask = 0; - if (!vfpriv->ring_idx_mask) + if (!vgdev->has_virgl_3d || !vfpriv || !vfpriv->ring_idx_mask) return drm_poll(filp, wait); poll_wait(filp, &drm_file->event_wait, wait); |