Skip to content

Commit

Permalink
drm/amdgpu: fix tear down order in amdgpu_vm_pt_free
Browse files Browse the repository at this point in the history
When freeing PD/PT with shadows it can happen that the shadow
destruction races with detaching the PD/PT from the VM causing a NULL
pointer dereference in the invalidation code.

Fix this by detaching the the PD/PT from the VM first and then
freeing the shadow instead.

Signed-off-by: Christian König <[email protected]>
Fixes: https://gitlab.freedesktop.org/drm/amd/-/issues/2867
Cc: <[email protected]>
Reviewed-by: Alex Deucher <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
  • Loading branch information
ChristianKoenigAMD authored and alexdeucher committed Dec 13, 2023
1 parent 2c7300d commit ceb9a32
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,14 @@ static void amdgpu_vm_pt_free(struct amdgpu_vm_bo_base *entry)

if (!entry->bo)
return;

entry->bo->vm_bo = NULL;
shadow = amdgpu_bo_shadowed(entry->bo);
if (shadow) {
ttm_bo_set_bulk_move(&shadow->tbo, NULL);
amdgpu_bo_unref(&shadow);
}
ttm_bo_set_bulk_move(&entry->bo->tbo, NULL);
entry->bo->vm_bo = NULL;

spin_lock(&entry->vm->status_lock);
list_del(&entry->vm_status);
Expand Down

0 comments on commit ceb9a32

Please sign in to comment.