public inbox for amd-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Add explicit NULL check for bo in amdgpu_vm_bo_update()
@ 2026-03-12 14:13 Srinivasan Shanmugam
  2026-03-12 14:39 ` Tvrtko Ursulin
  0 siblings, 1 reply; 4+ messages in thread
From: Srinivasan Shanmugam @ 2026-03-12 14:13 UTC (permalink / raw)
  To: Christian König, Alex Deucher
  Cc: amd-gfx, Srinivasan Shanmugam, Dan Carpenter, Tvrtko Ursulin

amdgpu_vm_bo_update() allows bo_va->base.bo to be NULL in some paths,
such as PRT-only updates.

Although amdgpu_vm_is_bo_always_valid() already returns false for a NULL
BO, Smatch still warns that bo may be NULL before it is dereferenced
later in the block.

Add an explicit `bo &&` check before calling
amdgpu_vm_is_bo_always_valid() to make the non-NULL condition clear and
fixes the below smatch error

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1353 amdgpu_vm_bo_update() error: we previously assumed 'bo' could be null (see line 1292)

Fixes: 26e20235ce00 ("drm/amdgpu: Add amdgpu_bo_is_vm_bo helper")
Cc: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index b89013a6aa0b..0d26346178d4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1349,7 +1349,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
 	 * the evicted list so that it gets validated again on the
 	 * next command submission.
 	 */
-	if (amdgpu_vm_is_bo_always_valid(vm, bo)) {
+	if (bo && amdgpu_vm_is_bo_always_valid(vm, bo)) {
 		if (bo->tbo.resource &&
 		    !(bo->preferred_domains &
 		      amdgpu_mem_type_to_domain(bo->tbo.resource->mem_type)))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-16 13:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 14:13 [PATCH] drm/amdgpu: Add explicit NULL check for bo in amdgpu_vm_bo_update() Srinivasan Shanmugam
2026-03-12 14:39 ` Tvrtko Ursulin
2026-03-12 17:21   ` Christian König
2026-03-16 10:07   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox