Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: amdgpu_device_recover_vram got NULL of shadow->parent

amdgpu_bo_destroy had a bug by calling amdgpu_bo_unref outside mutex_lock.
If amdgpu_device_recover_vram executed between amdgpu_bo_unref and list_del_init,
it would get NULL of shadow->parent, then caused Call Trace and GPU reset failed.

Signed-off-by: Wentao Lou <Wentao.Lou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

wentalou and committed by
Alex Deucher
36e499b2 20299a88

+3 -1
+3 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
··· 88 88 if (bo->gem_base.import_attach) 89 89 drm_prime_gem_destroy(&bo->gem_base, bo->tbo.sg); 90 90 drm_gem_object_release(&bo->gem_base); 91 - amdgpu_bo_unref(&bo->parent); 91 + /* in case amdgpu_device_recover_vram got NULL of bo->parent */ 92 92 if (!list_empty(&bo->shadow_list)) { 93 93 mutex_lock(&adev->shadow_list_lock); 94 94 list_del_init(&bo->shadow_list); 95 95 mutex_unlock(&adev->shadow_list_lock); 96 96 } 97 + amdgpu_bo_unref(&bo->parent); 98 + 97 99 kfree(bo->metadata); 98 100 kfree(bo); 99 101 }