Skip to content

Commit 7554886

Browse files
Luben Tuikovalexdeucher
authored andcommitted
drm/amdgpu: Fix size validation for non-exclusive domains (v4)
Fix amdgpu_bo_validate_size() to check whether the TTM domain manager for the requested memory exists, else we get a kernel oops when dereferencing "man". v2: Make the patch standalone, i.e. not dependent on local patches. v3: Preserve old behaviour and just check that the manager pointer is not NULL. v4: Complain if GTT domain requested and it is uninitialized--most likely a bug. Cc: Alex Deucher <[email protected]> Cc: Christian König <[email protected]> Cc: AMD Graphics <[email protected]> Signed-off-by: Luben Tuikov <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 28afcb0 commit 7554886

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -448,27 +448,24 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
448448

449449
/*
450450
* If GTT is part of requested domains the check must succeed to
451-
* allow fall back to GTT
451+
* allow fall back to GTT.
452452
*/
453453
if (domain & AMDGPU_GEM_DOMAIN_GTT) {
454454
man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
455455

456-
if (size < man->size)
456+
if (man && size < man->size)
457457
return true;
458-
else
459-
goto fail;
460-
}
461-
462-
if (domain & AMDGPU_GEM_DOMAIN_VRAM) {
458+
else if (!man)
459+
WARN_ON_ONCE("GTT domain requested but GTT mem manager uninitialized");
460+
goto fail;
461+
} else if (domain & AMDGPU_GEM_DOMAIN_VRAM) {
463462
man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
464463

465-
if (size < man->size)
464+
if (man && size < man->size)
466465
return true;
467-
else
468-
goto fail;
466+
goto fail;
469467
}
470468

471-
472469
/* TODO add more domains checks, such as AMDGPU_GEM_DOMAIN_CPU */
473470
return true;
474471

0 commit comments

Comments
 (0)