dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Fix stub fence refcount underflow
@ 2022-07-27 23:07 Felix Kuehling
       [not found] ` <CADnq5_NZyRAq+X-yQgJevbtgqjdh=FozCSUtM3wk9th4Np9DtQ@mail.gmail.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Felix Kuehling @ 2022-07-27 23:07 UTC (permalink / raw)
  To: amd-gfx, dri-devel; +Cc: Christian König

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 <christian.koenig@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 87a3a3ae9448..a6c7dcd8c345 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -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


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

* Re: [PATCH] drm/amdgpu: Fix stub fence refcount underflow
       [not found] ` <CADnq5_NZyRAq+X-yQgJevbtgqjdh=FozCSUtM3wk9th4Np9DtQ@mail.gmail.com>
@ 2022-07-28 14:01   ` Felix Kuehling
  0 siblings, 0 replies; 2+ messages in thread
From: Felix Kuehling @ 2022-07-28 14:01 UTC (permalink / raw)
  To: Alex Deucher; +Cc: dri-devel, amd-gfx, Christian König

Am 2022-07-27 um 23:52 schrieb Alex Deucher:
> On Wed, Jul 27, 2022 at 7:08 PM Felix Kuehling <Felix.Kuehling@amd.com> wrote:
>> 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 <christian.koenig@amd.com>
>> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

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


>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 1 -
>>   1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
>> index 87a3a3ae9448..a6c7dcd8c345 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
>> @@ -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
>>

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

end of thread, other threads:[~2022-07-28 14:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-27 23:07 [PATCH] drm/amdgpu: Fix stub fence refcount underflow Felix Kuehling
     [not found] ` <CADnq5_NZyRAq+X-yQgJevbtgqjdh=FozCSUtM3wk9th4Np9DtQ@mail.gmail.com>
2022-07-28 14:01   ` Felix Kuehling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).