mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 1/2] drm/amdgpu: clear job on failure in amdgpu_job_alloc(_with_ib)
@ 2025-11-24 16:36 Pierre-Eric Pelloux-Prayer
  2025-11-24 16:36 ` [PATCH v1 2/2] drm/amdgpu: free job fences on failure in amdgpu_job_alloc_with_ib Pierre-Eric Pelloux-Prayer
  2025-11-24 19:25 ` [PATCH v1 1/2] drm/amdgpu: clear job on failure in amdgpu_job_alloc(_with_ib) Christian König
  0 siblings, 2 replies; 4+ messages in thread
From: Pierre-Eric Pelloux-Prayer @ 2025-11-24 16:36 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	David (Ming Qiang) Wu
  Cc: Pierre-Eric Pelloux-Prayer, amd-gfx, dri-devel, linux-kernel

If memory is freed we need to nullify the pointer or the caller
might call kfree again (eg: amdgpu_cs_parser_fini calls kfree on
all non-null job pointers).

Fixes: a35c520c1611 ("drm/amdgpu: clean up and unify hw fence handling")
Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index efa3281145f6..2fc3d9da0fe7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -225,6 +225,7 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	kfree((*job)->hw_fence);
 err_job:
 	kfree(*job);
+	*job = NULL;
 
 	return r;
 }
@@ -246,6 +247,7 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev,
 		if (entity)
 			drm_sched_job_cleanup(&(*job)->base);
 		kfree(*job);
+		*job = NULL;
 	}
 
 	return r;
-- 
2.43.0


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

* [PATCH v1 2/2] drm/amdgpu: free job fences on failure in amdgpu_job_alloc_with_ib
  2025-11-24 16:36 [PATCH v1 1/2] drm/amdgpu: clear job on failure in amdgpu_job_alloc(_with_ib) Pierre-Eric Pelloux-Prayer
@ 2025-11-24 16:36 ` Pierre-Eric Pelloux-Prayer
  2025-11-24 17:00   ` Alex Deucher
  2025-11-24 19:25 ` [PATCH v1 1/2] drm/amdgpu: clear job on failure in amdgpu_job_alloc(_with_ib) Christian König
  1 sibling, 1 reply; 4+ messages in thread
From: Pierre-Eric Pelloux-Prayer @ 2025-11-24 16:36 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	David (Ming Qiang) Wu
  Cc: Pierre-Eric Pelloux-Prayer, amd-gfx, dri-devel, linux-kernel

Otherwise we're leaking memory.

Fixes: a35c520c1611 ("drm/amdgpu: clean up and unify hw fence handling")
Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index 2fc3d9da0fe7..91f1232b7d41 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -246,6 +246,8 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev,
 	if (r) {
 		if (entity)
 			drm_sched_job_cleanup(&(*job)->base);
+		kfree((*job)->hw_vm_fence);
+		kfree((*job)->hw_fence);
 		kfree(*job);
 		*job = NULL;
 	}
-- 
2.43.0


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

* Re: [PATCH v1 2/2] drm/amdgpu: free job fences on failure in amdgpu_job_alloc_with_ib
  2025-11-24 16:36 ` [PATCH v1 2/2] drm/amdgpu: free job fences on failure in amdgpu_job_alloc_with_ib Pierre-Eric Pelloux-Prayer
@ 2025-11-24 17:00   ` Alex Deucher
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2025-11-24 17:00 UTC (permalink / raw)
  To: Pierre-Eric Pelloux-Prayer
  Cc: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	David (Ming Qiang) Wu, amd-gfx, dri-devel, linux-kernel

On Mon, Nov 24, 2025 at 11:44 AM Pierre-Eric Pelloux-Prayer
<pierre-eric.pelloux-prayer@amd.com> wrote:
>
> Otherwise we're leaking memory.
>
> Fixes: a35c520c1611 ("drm/amdgpu: clean up and unify hw fence handling")
> Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>

Series is:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
> index 2fc3d9da0fe7..91f1232b7d41 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
> @@ -246,6 +246,8 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev,
>         if (r) {
>                 if (entity)
>                         drm_sched_job_cleanup(&(*job)->base);
> +               kfree((*job)->hw_vm_fence);
> +               kfree((*job)->hw_fence);
>                 kfree(*job);
>                 *job = NULL;
>         }
> --
> 2.43.0
>

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

* Re: [PATCH v1 1/2] drm/amdgpu: clear job on failure in amdgpu_job_alloc(_with_ib)
  2025-11-24 16:36 [PATCH v1 1/2] drm/amdgpu: clear job on failure in amdgpu_job_alloc(_with_ib) Pierre-Eric Pelloux-Prayer
  2025-11-24 16:36 ` [PATCH v1 2/2] drm/amdgpu: free job fences on failure in amdgpu_job_alloc_with_ib Pierre-Eric Pelloux-Prayer
@ 2025-11-24 19:25 ` Christian König
  1 sibling, 0 replies; 4+ messages in thread
From: Christian König @ 2025-11-24 19:25 UTC (permalink / raw)
  To: Pierre-Eric Pelloux-Prayer, Alex Deucher, David Airlie,
	Simona Vetter, David (Ming Qiang) Wu
  Cc: amd-gfx, dri-devel, linux-kernel

On 11/24/25 17:36, Pierre-Eric Pelloux-Prayer wrote:
> If memory is freed we need to nullify the pointer or the caller
> might call kfree again (eg: amdgpu_cs_parser_fini calls kfree on
> all non-null job pointers).
> 
> Fixes: a35c520c1611 ("drm/amdgpu: clean up and unify hw fence handling")
> Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com> for both patches.

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
> index efa3281145f6..2fc3d9da0fe7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
> @@ -225,6 +225,7 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm,
>  	kfree((*job)->hw_fence);
>  err_job:
>  	kfree(*job);
> +	*job = NULL;
>  
>  	return r;
>  }
> @@ -246,6 +247,7 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev,
>  		if (entity)
>  			drm_sched_job_cleanup(&(*job)->base);
>  		kfree(*job);
> +		*job = NULL;
>  	}
>  
>  	return r;


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

end of thread, other threads:[~2025-11-24 19:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-24 16:36 [PATCH v1 1/2] drm/amdgpu: clear job on failure in amdgpu_job_alloc(_with_ib) Pierre-Eric Pelloux-Prayer
2025-11-24 16:36 ` [PATCH v1 2/2] drm/amdgpu: free job fences on failure in amdgpu_job_alloc_with_ib Pierre-Eric Pelloux-Prayer
2025-11-24 17:00   ` Alex Deucher
2025-11-24 19:25 ` [PATCH v1 1/2] drm/amdgpu: clear job on failure in amdgpu_job_alloc(_with_ib) Christian König

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

all inboxes | Powered by JetHome®