Skip to content

Commit 491adc6

Browse files
GyrosGeiermbrost05
authored andcommitted
drm/ttm: Avoid NULL pointer deref for evicted BOs
It is possible for a BO to exist that is not currently associated with a resource, e.g. because it has been evicted. When devcoredump tries to read the contents of all BOs for dumping, we need to expect this as well -- in this case, ENODATA is recorded instead of the buffer contents. Fixes: 7d08df5 ("drm/ttm: Add ttm_bo_access") Fixes: 09ac4fc ("drm/ttm: Implement vm_operations_struct.access v2") Cc: stable <stable@kernel.org> Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/6271 Signed-off-by: Simon Richter <Simon.Richter@hogyros.de> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Shuicheng Lin <shuicheng.lin@intel.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Link: https://patch.msgid.link/20251013161241.709916-1-Simon.Richter@hogyros.de
1 parent 979e2ec commit 491adc6

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/gpu/drm/ttm/ttm_bo_vm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,11 @@ int ttm_bo_access(struct ttm_buffer_object *bo, unsigned long offset,
434434
if (ret)
435435
return ret;
436436

437+
if (!bo->resource) {
438+
ret = -ENODATA;
439+
goto unlock;
440+
}
441+
437442
switch (bo->resource->mem_type) {
438443
case TTM_PL_SYSTEM:
439444
fallthrough;
@@ -448,6 +453,7 @@ int ttm_bo_access(struct ttm_buffer_object *bo, unsigned long offset,
448453
ret = -EIO;
449454
}
450455

456+
unlock:
451457
ttm_bo_unreserve(bo);
452458

453459
return ret;

0 commit comments

Comments
 (0)