i915_vma_pin_ww() allocates bind work before retrieving the object's
moving fence. If the lookup fails, it jumps to err_rpm, bypassing the
fence commit at err_fence and leaking the work allocation.

Jump to err_fence instead so the fence callbacks can release the work.

Fixes: 8ec5c0006c50 ("Merge tag 'drm-intel-next-2022-05-20' of 
git://anongit.freedesktop.org/drm/drm-intel into drm-intel-gt-next")
Signed-off-by: Haoxiang Li <[email protected]>
---
 drivers/gpu/drm/i915/i915_vma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index 16782d8579a8..4ba1c9ea5ecb 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -1470,7 +1470,7 @@ int i915_vma_pin_ww(struct i915_vma *vma, struct 
i915_gem_ww_ctx *ww,
 
                err = i915_gem_object_get_moving_fence(vma->obj, &moving);
                if (err)
-                       goto err_rpm;
+                       goto err_fence;
 
                dma_fence_work_chain(&work->base, moving);
 
-- 
2.25.1

Reply via email to