]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu/ttm: Fix crash when handling MMIO_REMAP in PDE flags
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Tue, 18 Nov 2025 08:58:33 +0000 (14:28 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 19 Nov 2025 22:34:15 +0000 (17:34 -0500)
The MMIO_REMAP BO is a special 4K IO page that does not have a ttm_tt
behind it. However, amdgpu_ttm_tt_pde_flags() was treating it like
normal TT/doorbell/preempt memory and unconditionally accessed
ttm->caching. For the MMIO_REMAP BO, ttm is NULL, so this leads to a
NULL pointer dereference when computing PDE flags.

Fix this by checking that ttm is non-NULL before reading ttm->caching.
This prevents the crash for MMIO_REMAP and also makes the code more
defensive if other BOs ever come through without a ttm_tt.

Fixes: fb5a52dbe9fe ("drm/amdgpu: Implement TTM handling for MMIO_REMAP placement")
Suggested-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Jesse Zhang <Jesse.Zhang@amd.com>
Tested-by: Jesse Zhang <Jesse.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

index 838a51b6098b45ee9838865379dd79a2143c3a7b..5475f7117f10186603dee5029967a8fe4a569b23 100644 (file)
@@ -1329,7 +1329,7 @@ uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_resource *mem)
                    mem->mem_type == AMDGPU_PL_MMIO_REMAP)) {
                flags |= AMDGPU_PTE_SYSTEM;
 
-               if (ttm->caching == ttm_cached)
+               if (ttm && ttm->caching == ttm_cached)
                        flags |= AMDGPU_PTE_SNOOPED;
        }