Skip to contentSkip to conversation

drm/amdgpu: NULL-check BO's backing store when determining GFX12 PTE flags

PATCH Applied Natalie Vock 3 participants 3 messages Mar 10, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: NULL-check BO's backing store when determining GFX12 PTE flags

PRT BOs may not have any backing store, so bo->tbo.resource will be NULL. Check for that before dereferencing.

Fixes 0cce5f285d9ae8 ("drm/amdkfd: Check correct memory types for is_system variable")
---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +3 -2
index ea7c32d8380ba..bf8d01da88154 100644
@@ -528,8 +528,9 @@ static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev,
 
 	bo_adev = amdgpu_ttm_adev(bo->tbo.bdev);
 	coherent = bo->flags & AMDGPU_GEM_CREATE_COHERENT;
-	is_system = (bo->tbo.resource->mem_type == TTM_PL_TT) ||
-		(bo->tbo.resource->mem_type == AMDGPU_PL_PREEMPT);
+	is_system = bo->tbo.resource &&
+		(bo->tbo.resource->mem_type == TTM_PL_TT ||
+		 bo->tbo.resource->mem_type == AMDGPU_PL_PREEMPT);
 
 	if (bo && bo->flags & AMDGPU_GEM_CREATE_GFX12_DCC)
 		*flags |= AMDGPU_PTE_DCC;

--
2.48.1

maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 10.03.25 um 18:08 schrieb Natalie Vock:

Quoted 5 lines

PRT BOs may not have any backing store, so bo->tbo.resource will be NULL. Check for that before dereferencing.

Fixes 0cce5f285d9ae8 ("drm/amdkfd: Check correct memory types for is_system variable")
Quoted 23 lines
---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +3 -3
index ea7c32d8380ba..bf8d01da88154 100644
@@ -528,8 +528,9 @@ static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev,
 
 	bo_adev = amdgpu_ttm_adev(bo->tbo.bdev);
 	coherent = bo->flags & AMDGPU_GEM_CREATE_COHERENT;
-	is_system = (bo->tbo.resource->mem_type == TTM_PL_TT) ||
-		(bo->tbo.resource->mem_type == AMDGPU_PL_PREEMPT);
+	is_system = bo->tbo.resource &&
+		(bo->tbo.resource->mem_type == TTM_PL_TT ||
+		 bo->tbo.resource->mem_type == AMDGPU_PL_PREEMPT);
 
 	if (bo && bo->flags & AMDGPU_GEM_CREATE_GFX12_DCC)
 		*flags |= AMDGPU_PTE_DCC;
--

2.48.1

Applied
#2 lore raw

Applied. Thanks!

Quoted 34 lines · Christian König

Am 10.03.25 um 18:08 schrieb Natalie Vock:

Quoted 5 lines

PRT BOs may not have any backing store, so bo->tbo.resource will be NULL. Check for that before dereferencing.

Fixes 0cce5f285d9ae8 ("drm/amdkfd: Check correct memory types for is_system variable")
Quoted 23 lines
---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +3 -3
index ea7c32d8380ba..bf8d01da88154 100644
@@ -528,8 +528,9 @@ static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev,
 
      bo_adev = amdgpu_ttm_adev(bo->tbo.bdev);
      coherent = bo->flags & AMDGPU_GEM_CREATE_COHERENT;
-     is_system = (bo->tbo.resource->mem_type == TTM_PL_TT) ||
-             (bo->tbo.resource->mem_type == AMDGPU_PL_PREEMPT);
+     is_system = bo->tbo.resource &&
+             (bo->tbo.resource->mem_type == TTM_PL_TT ||
+              bo->tbo.resource->mem_type == AMDGPU_PL_PREEMPT);
 
      if (bo && bo->flags & AMDGPU_GEM_CREATE_GFX12_DCC)
              *flags |= AMDGPU_PTE_DCC;
--

2.48.1