AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] amdkfd: properly free gang_ctx_bo when failed to init user queue
@ 2025-02-05  8:08 Zhu Lingshan
  2025-02-05 16:49 ` Felix Kuehling
  0 siblings, 1 reply; 2+ messages in thread
From: Zhu Lingshan @ 2025-02-05  8:08 UTC (permalink / raw)
  To: Felix.Kuehling, alexander.deucher; +Cc: ray.huang, amd-gfx, Zhu Lingshan

The destructor of a gtt bo is declared as
void amdgpu_amdkfd_free_gtt_mem(struct amdgpu_device *adev, void **mem_obj);
Which takes void** as the second parameter.

GCC allows passing void* to the function because void* can be implicitly
casted to any other types, so it can pass compiling.

However, passing this void* parameter into the function's
execution process(which expects void** and dereferencing void**)
will result in errors.

Signed-off-by: Zhu Lingshan <lingshan.zhu@amd.com>
Fixes: fb91065851cd ("drm/amdkfd: Refactor queue wptr_bo GART mapping")
---
 drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
index 750f967fecf5..0ce8d49ca16e 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
@@ -295,7 +295,7 @@ static int init_user_queue(struct process_queue_manager *pqm,
 	return 0;
 
 free_gang_ctx_bo:
-	amdgpu_amdkfd_free_gtt_mem(dev->adev, (*q)->gang_ctx_bo);
+	amdgpu_amdkfd_free_gtt_mem(dev->adev, &(*q)->gang_ctx_bo);
 cleanup:
 	uninit_queue(*q);
 	*q = NULL;
-- 
2.43.5


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

* Re: [PATCH] amdkfd: properly free gang_ctx_bo when failed to init user queue
  2025-02-05  8:08 [PATCH] amdkfd: properly free gang_ctx_bo when failed to init user queue Zhu Lingshan
@ 2025-02-05 16:49 ` Felix Kuehling
  0 siblings, 0 replies; 2+ messages in thread
From: Felix Kuehling @ 2025-02-05 16:49 UTC (permalink / raw)
  To: Zhu Lingshan, alexander.deucher; +Cc: ray.huang, amd-gfx



On 2025-02-05 3:08, Zhu Lingshan wrote:
> The destructor of a gtt bo is declared as
> void amdgpu_amdkfd_free_gtt_mem(struct amdgpu_device *adev, void **mem_obj);
> Which takes void** as the second parameter.
> 
> GCC allows passing void* to the function because void* can be implicitly
> casted to any other types, so it can pass compiling.
> 
> However, passing this void* parameter into the function's
> execution process(which expects void** and dereferencing void**)
> will result in errors.
> 
> Signed-off-by: Zhu Lingshan <lingshan.zhu@amd.com>
> Fixes: fb91065851cd ("drm/amdkfd: Refactor queue wptr_bo GART mapping")

Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>


> ---
>  drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> index 750f967fecf5..0ce8d49ca16e 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> @@ -295,7 +295,7 @@ static int init_user_queue(struct process_queue_manager *pqm,
>  	return 0;
>  
>  free_gang_ctx_bo:
> -	amdgpu_amdkfd_free_gtt_mem(dev->adev, (*q)->gang_ctx_bo);
> +	amdgpu_amdkfd_free_gtt_mem(dev->adev, &(*q)->gang_ctx_bo);
>  cleanup:
>  	uninit_queue(*q);
>  	*q = NULL;


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

end of thread, other threads:[~2025-02-05 17:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-05  8:08 [PATCH] amdkfd: properly free gang_ctx_bo when failed to init user queue Zhu Lingshan
2025-02-05 16:49 ` Felix Kuehling

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