Hello Christian König,

Commit 59e4405e9ee2 ("drm/amdgpu: revert to old status lock handling
v3") from Aug 27, 2025 (linux-next), leads to the following Smatch
static checker warning:

        drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:310 
amdgpu_vm_bo_reset_state_machine()
        warn: iterator used outside loop: 'vm_bo'

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
    300 static void amdgpu_vm_bo_reset_state_machine(struct amdgpu_vm *vm)
    301 {
    302         struct amdgpu_vm_bo_base *vm_bo, *tmp;
    303 
    304         spin_lock(&vm->invalidated_lock);
    305         list_splice_init(&vm->done, &vm->invalidated);
    306         list_for_each_entry(vm_bo, &vm->invalidated, vm_status)
    307                 vm_bo->moved = true;
    308         spin_unlock(&vm->invalidated_lock);
    309 
--> 310         amdgpu_vm_assert_locked(vm_bo->vm);
                                        ^^^^^
vm_bo is an invalid pointer at this point.  We exited the loop without
hitting a break.

    311         list_for_each_entry_safe(vm_bo, tmp, &vm->idle, vm_status) {
    312                 struct amdgpu_bo *bo = vm_bo->bo;
    313 
    314                 vm_bo->moved = true;
    315                 if (!bo || bo->tbo.type != ttm_bo_type_kernel)
    316                         list_move(&vm_bo->vm_status, &vm_bo->vm->moved);
    317                 else if (bo->parent)
    318                         list_move(&vm_bo->vm_status, 
&vm_bo->vm->relocated);
    319         }
    320 }

regards,
dan carpenter

Reply via email to