Skip to contentSkip to conversation

drm/amdgpu: Fix last_update fence leak in amdgpu_vm_init()

PATCH Applied Wentao Liang 2 participants 2 messages Sep 16

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix last_update fence leak in amdgpu_vm_init()

amdgpu_vm_init() initializes vm->last_update, vm->last_unlocked and vm->last_tlb_flush with references to the stub fence taken via dma_fence_get_stub(). The error label at the end of the function releases the last_unlocked and last_tlb_flush references with dma_fence_put(), but the reference stored in vm->last_update is never dropped, so whenever the page table root creation, the reservation of the root BO or the PASID registration fails, the stub fence reference leaks.

Drop the vm->last_update reference together with the other stub fence references on the error path.

Fixes 187916e6ed9d ("drm/amdgpu: install stub fence into potential unused fence pointers")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -0
index fccd758b6699..494197ac20e8 100644
@@ -2693,6 +2693,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	amdgpu_bo_unref(&root_bo);
 
 error_free_delayed:
+	dma_fence_put(vm->last_update);
 	dma_fence_put(vm->last_tlb_flush);
 	dma_fence_put(vm->last_unlocked);
 	ttm_lru_bulk_move_fini(&adev->mman.bdev, &vm->lru_bulk_move);
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw

AMD General

Applied. Thanks!

Quoted 47 lines

-----Original Message-----
From: Wentao Liang <[email protected]>
Sent: Wednesday, September 16, 2026 5:56 AM
To: Yu, Lang <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; [email protected]; Koenig, Christian <[email protected]>; [email protected]; linux- [email protected]; [email protected]; Wentao Liang <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: Fix last_update fence leak in amdgpu_vm_init()

amdgpu_vm_init() initializes vm->last_update, vm->last_unlocked and vm->last_tlb_flush with references to the stub fence taken via dma_fence_get_stub(). The error label at the end of the function releases the last_unlocked and last_tlb_flush references with dma_fence_put(), but the reference stored in vm->last_update is never dropped, so whenever the page table root creation, the reservation of the root BO or the PASID registration fails, the stub fence reference leaks.

Drop the vm->last_update reference together with the other stub fence references on the error path.

Fixes 187916e6ed9d ("drm/amdgpu: install stub fence into potential unused

fence pointers")

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -0
index fccd758b6699..494197ac20e8 100644
@@ -2693,6 +2693,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev,
 struct amdgpu_vm *vm,
      amdgpu_bo_unref(&root_bo);
 
 error_free_delayed:
+     dma_fence_put(vm->last_update);
      dma_fence_put(vm->last_tlb_flush);
      dma_fence_put(vm->last_unlocked);
      ttm_lru_bulk_move_fini(&adev->mman.bdev, &vm->lru_bulk_move);

--
2.34.1