intel_vgpu_pin_mm() unconditionally increments the mm's pincount at
the start. If the subsequent shadow ppgtt creation fails, the
function returns an error but leaves the pincount incremented.
Callers must therefore always call intel_vgpu_unpin_mm() after
intel_vgpu_pin_mm() returns, regardless of success or failure, to
balance the reference.
In intel_vgpu_shadow_mm_pin(), when the pinning of the shadow mm
fails, the error path returns immediately without unpinning. This
leaks the pincount reference that was already taken. All other error
paths in the same function correctly unpin on failure, making this an
obvious omission.
Add the missing intel_vgpu_unpin_mm() call before returning the error.
Cc: stable@vger.kernel.org
Fixes: d8235b5e5584 ("drm/i915/gvt: Move common workload preparation into prepare_workload()")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/gpu/drm/i915/gvt/scheduler.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
index 15fdd514ca83..30d879b37c84 100644
--- a/drivers/gpu/drm/i915/gvt/scheduler.c
+++ b/drivers/gpu/drm/i915/gvt/scheduler.c
@@ -698,6 +698,7 @@ intel_vgpu_shadow_mm_pin(struct intel_vgpu_workload *workload)
ret = intel_vgpu_pin_mm(workload->shadow_mm);
if (ret) {
+ intel_vgpu_unpin_mm(workload->shadow_mm);
gvt_vgpu_err("fail to vgpu pin mm\n");
return ret;
}
--
2.34.1