Skip to contentSkip to conversation

drm/amdgpu: Fix stub fence refcount underflow

PATCH In review Felix Kuehling 1 participant 2 messages Jul 27, 2022 – Jul 28, 2022 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Felix Kuehling

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix stub fence refcount underflow

Don't drop the stub fence reference after installing it as a replacement for the eviction fence. dma_resv_replace_fences doesn't take another reference to the fence, so it takes ownership of the reference passed in by us.

Fixes 548e7432dc2d ("dma-buf: add dma_resv_replace_fences v2")
CC Christian König <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -1
index 87a3a3ae9448..a6c7dcd8c345 100644
@@ -294,7 +294,6 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
 	replacement = dma_fence_get_stub();
 	dma_resv_replace_fences(bo->tbo.base.resv, ef->base.context,
 				replacement, DMA_RESV_USAGE_READ);
-	dma_fence_put(replacement);
 	return 0;
 }
 
Signature · 1 line
2.32.0

A message that is not in the archive (sent off-list or not yet received): CADnq5_NZyRAq+X-yQgJevbtgqjdh=FozCSUtM3wk9th4Np9DtQ@mail.gmail.com

author maintainer
#2 lore raw

Am 2022-07-27 um 23:52 schrieb Alex Deucher:

Quoted 10 lines · Felix Kuehling
Quoted 8 lines

Don't drop the stub fence reference after installing it as a replacement for the eviction fence. dma_resv_replace_fences doesn't take another reference to the fence, so it takes ownership of the reference passed in by us.

Fixes 548e7432dc2d ("dma-buf: add dma_resv_replace_fences v2")
CC Christian König <[email protected]>

This patch is the wrong solution. Xinhui added a dma_fence_get in dma_resv_replace_fences in his patch "dma-buf: Fix one use-after-free of fence". So this patch is not needed any more.

Regards,
  Felix

Quoted 19 lines
Quoted 19 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 1 -
  1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -2
index 87a3a3ae9448..a6c7dcd8c345 100644
@@ -294,7 +294,6 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
         replacement = dma_fence_get_stub();
         dma_resv_replace_fences(bo->tbo.base.resv, ef->base.context,
                                 replacement, DMA_RESV_USAGE_READ);
-       dma_fence_put(replacement);
         return 0;
  }
 
--

2.32.0