Skip to content

Commit

Permalink
drm/virtio: add fence sanity check
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Gerd Hoffmann committed Sep 4, 2019
1 parent 6e33725 commit 12afce0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/gpu/drm/virtio/virtgpu_fence.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 12afce0

Please sign in to comment.