Commit c72d41a8 authored by Christian König's avatar Christian König Committed by Alex Deucher
Browse files

drm/amdgpu: grab a BO reference in vm_lock_done_list.



Otherwise it is possible that between dropping the status lock and
locking the BO that the BO is freed up.

Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarSunil Khatri <sunil.khatri@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 7cf422ed
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -484,15 +484,19 @@ int amdgpu_vm_lock_done_list(struct amdgpu_vm *vm, struct drm_exec *exec,
	spin_lock(&vm->status_lock);
	while (!list_is_head(prev->next, &vm->done)) {
		bo_va = list_entry(prev->next, typeof(*bo_va), base.vm_status);
		spin_unlock(&vm->status_lock);

		bo = bo_va->base.bo;
		if (bo) {
			amdgpu_bo_ref(bo);
			spin_unlock(&vm->status_lock);

			ret = drm_exec_prepare_obj(exec, &bo->tbo.base, 1);
			amdgpu_bo_unref(&bo);
			if (unlikely(ret))
				return ret;
		}

			spin_lock(&vm->status_lock);
		}
		prev = prev->next;
	}
	spin_unlock(&vm->status_lock);