From: Felix Kuehling Date: Tue, 31 Oct 2023 17:30:00 +0000 (-0400) Subject: drm/amdgpu: Fix possible null pointer dereference X-Git-Tag: v6.6.7~502 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e4d9fda7e65cd267900f7d2c7c1579a98bf413c;p=platform%2Fkernel%2Flinux-starfive.git drm/amdgpu: Fix possible null pointer dereference commit 256503071c2de2b5b5c20e06654aa9a44f13aa62 upstream. mem = bo->tbo.resource may be NULL in amdgpu_vm_bo_update. Fixes: 180253782038 ("drm/ttm: stop allocating dummy resources during BO creation") Signed-off-by: Felix Kuehling Reviewed-by: Christian König Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 9ab87a5..89c8e51 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -1095,8 +1095,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va, bo = gem_to_amdgpu_bo(gobj); } mem = bo->tbo.resource; - if (mem->mem_type == TTM_PL_TT || - mem->mem_type == AMDGPU_PL_PREEMPT) + if (mem && (mem->mem_type == TTM_PL_TT || + mem->mem_type == AMDGPU_PL_PREEMPT)) pages_addr = bo->tbo.ttm->dma_address; }