Skip to content

Commit 537457a

Browse files
icklerodrigovivi
authored andcommitted
drm/i915: Hold onto an explicit ref to i915_vma_work.pinned
Since __vma_release is run by a kworker after the fence has been signaled, it is no longer protected by the active reference on the vma, and so the alias of vw->pinned to vma->obj is also not protected by a reference on the object. Add an explicit reference for vw->pinned so it will always be safe. Found by inspection. Fixes: 54d7195 ("drm/i915: Unpin vma->obj on early error") Reported-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: <stable@vger.kernel.org> # v5.6+ Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20201102161931.30031-1-chris@chris-wilson.co.uk (cherry picked from commit bc73e5d33048b7ab5f12b11b5d923700467a8e1d) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent e67d01d commit 537457a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/gpu/drm/i915/i915_vma.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,10 @@ static void __vma_release(struct dma_fence_work *work)
314314
{
315315
struct i915_vma_work *vw = container_of(work, typeof(*vw), base);
316316

317-
if (vw->pinned)
317+
if (vw->pinned) {
318318
__i915_gem_object_unpin_pages(vw->pinned);
319+
i915_gem_object_put(vw->pinned);
320+
}
319321

320322
i915_vm_free_pt_stash(vw->vm, &vw->stash);
321323
i915_vm_put(vw->vm);
@@ -431,7 +433,7 @@ int i915_vma_bind(struct i915_vma *vma,
431433

432434
if (vma->obj) {
433435
__i915_gem_object_pin_pages(vma->obj);
434-
work->pinned = vma->obj;
436+
work->pinned = i915_gem_object_get(vma->obj);
435437
}
436438
} else {
437439
vma->ops->bind_vma(vma->vm, NULL, vma, cache_level, bind_flags);

0 commit comments

Comments
 (0)