drm/amdgpu: Fix possible null pointer dereference
authorFelix Kuehling <Felix.Kuehling@amd.com>
Tue, 17 Oct 2023 20:51:03 +0000 (16:51 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 19 Oct 2023 22:26:52 +0000 (18:26 -0400)
abo->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>
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

index afc19341334ffacc281ba020081a9535f5b07bd7..f3c9f93d8899c82c4d0bbbbd70a5f55fde352c9b 100644 (file)
@@ -1090,7 +1090,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
                        struct drm_gem_object *gobj = dma_buf->priv;
                        struct amdgpu_bo *abo = gem_to_amdgpu_bo(gobj);
 
-                       if (abo->tbo.resource->mem_type == TTM_PL_VRAM)
+                       if (abo->tbo.resource &&
+                           abo->tbo.resource->mem_type == TTM_PL_VRAM)
                                bo = gem_to_amdgpu_bo(gobj);
                }
                mem = bo->tbo.resource;