summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-08-29 12:33:01 +0200
committerGerd Hoffmann <kraxel@redhat.com>2019-09-04 06:54:12 +0200
commit12afce08ed51a67aafcc678f4b6e428d71b1f6fb (patch)
treef9b321809d84716ede2edc6f8c47a536ecabc39d
parent6e3372508d5ffee81396edfc23259bd042d35de6 (diff)
drm/virtio: add fence sanity check
Make sure we don't leak half-initialized fences outside the driver. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20190829103301.3539-19-kraxel@redhat.com
-rw-r--r--drivers/gpu/drm/virtio/virtgpu_fence.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c
index a0514f5bd006..a4b9881ca1d3 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fence.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fence.c
@@ -41,6 +41,10 @@ bool virtio_fence_signaled(struct dma_fence *f)
{
struct virtio_gpu_fence *fence = to_virtio_fence(f);
+ if (WARN_ON_ONCE(fence->f.seqno == 0))
+ /* leaked fence outside driver before completing
+ * initialization with virtio_gpu_fence_emit */
+ return false;
if (atomic64_read(&fence->drv->last_seq) >= fence->f.seqno)
return true;
return false;