drm/amdgpu: fixx NULL pointer deref in gmc_v9_0_get_vm_pte
authorChristian König <christian.koenig@amd.com>
Wed, 7 Dec 2022 07:47:30 +0000 (08:47 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 14 Dec 2022 14:48:04 +0000 (09:48 -0500)
We not only need to make sure that we have a BO, but also that the BO
has some backing store.

Fixes: d1a372af1c3d ("drm/amdgpu: Set MTYPE in PTE based on BO flags")
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Luben Tuikov <luben.tuikov@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c

index 50386eb..08d6cf7 100644 (file)
@@ -1185,6 +1185,8 @@ static void gmc_v9_0_get_vm_pte(struct amdgpu_device *adev,
                                struct amdgpu_bo_va_mapping *mapping,
                                uint64_t *flags)
 {
+       struct amdgpu_bo *bo = mapping->bo_va->base.bo;
+
        *flags &= ~AMDGPU_PTE_EXECUTABLE;
        *flags |= mapping->flags & AMDGPU_PTE_EXECUTABLE;
 
@@ -1196,7 +1198,7 @@ static void gmc_v9_0_get_vm_pte(struct amdgpu_device *adev,
                *flags &= ~AMDGPU_PTE_VALID;
        }
 
-       if (mapping->bo_va->base.bo)
+       if (bo && bo->tbo.resource)
                gmc_v9_0_get_coherence_flags(adev, mapping->bo_va->base.bo,
                                             mapping, flags);
 }