drm/amdgpu: Fix possible null pointer dereference
authorFelix Kuehling <Felix.Kuehling@amd.com>
Tue, 31 Oct 2023 17:30:00 +0000 (13:30 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 10 Nov 2023 16:33:28 +0000 (11:33 -0500)
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 <Felix.Kuehling@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

index 904252456d2582d8da3bfe5f6fad647ec24b3627..100497cb19e66fcffb7ddac6d578cf5a9fd88d77 100644 (file)
@@ -1098,8 +1098,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;
        }