All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdkfd: Fix memory leak in create_process failure
@ 2024-04-10 20:04 Felix Kuehling
  2024-04-10 20:09 ` Kasiviswanathan, Harish
  2024-04-10 21:08 ` Joshi, Mukul
  0 siblings, 2 replies; 3+ messages in thread
From: Felix Kuehling @ 2024-04-10 20:04 UTC (permalink / raw)
  To: amd-gfx; +Cc: Xiaogang Chen

Fix memory leak due to a leaked mmget reference on an error handling
code path that is triggered when attempting to create KFD processes
while a GPU reset is in progress.

Fixes: 0ab2d7532b05 ("drm/amdkfd: prepare per-process debug enable and disable")
CC: Xiaogang Chen <xiaogang.chen@amd.com>
Signed-off-by: Felix Kuehling <felix.kuehling@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_process.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 717a60d7a4ea..b79986412cd8 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -819,9 +819,9 @@ struct kfd_process *kfd_create_process(struct task_struct *thread)
 	mutex_lock(&kfd_processes_mutex);
 
 	if (kfd_is_locked()) {
-		mutex_unlock(&kfd_processes_mutex);
 		pr_debug("KFD is locked! Cannot create process");
-		return ERR_PTR(-EINVAL);
+		process = ERR_PTR(-EINVAL);
+		goto out;
 	}
 
 	/* A prior open of /dev/kfd could have already created the process. */
-- 
2.34.1


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

* RE: [PATCH] drm/amdkfd: Fix memory leak in create_process failure
  2024-04-10 20:04 [PATCH] drm/amdkfd: Fix memory leak in create_process failure Felix Kuehling
@ 2024-04-10 20:09 ` Kasiviswanathan, Harish
  2024-04-10 21:08 ` Joshi, Mukul
  1 sibling, 0 replies; 3+ messages in thread
From: Kasiviswanathan, Harish @ 2024-04-10 20:09 UTC (permalink / raw)
  To: Kuehling, Felix, amd-gfx; +Cc: Chen, Xiaogang

[AMD Official Use Only - General]

Tested-by: Harish Kasiviswanthan <Harish.Kasiviswanthan@amd.com>

-----Original Message-----
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Felix Kuehling
Sent: Wednesday, April 10, 2024 4:05 PM
To: amd-gfx@lists.freedesktop.org
Cc: Chen, Xiaogang <Xiaogang.Chen@amd.com>
Subject: [PATCH] drm/amdkfd: Fix memory leak in create_process failure

Fix memory leak due to a leaked mmget reference on an error handling
code path that is triggered when attempting to create KFD processes
while a GPU reset is in progress.

Fixes: 0ab2d7532b05 ("drm/amdkfd: prepare per-process debug enable and disable")
CC: Xiaogang Chen <xiaogang.chen@amd.com>
Signed-off-by: Felix Kuehling <felix.kuehling@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_process.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 717a60d7a4ea..b79986412cd8 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -819,9 +819,9 @@ struct kfd_process *kfd_create_process(struct task_struct *thread)
        mutex_lock(&kfd_processes_mutex);

        if (kfd_is_locked()) {
-               mutex_unlock(&kfd_processes_mutex);
                pr_debug("KFD is locked! Cannot create process");
-               return ERR_PTR(-EINVAL);
+               process = ERR_PTR(-EINVAL);
+               goto out;
        }

        /* A prior open of /dev/kfd could have already created the process. */
--
2.34.1


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

* RE: [PATCH] drm/amdkfd: Fix memory leak in create_process failure
  2024-04-10 20:04 [PATCH] drm/amdkfd: Fix memory leak in create_process failure Felix Kuehling
  2024-04-10 20:09 ` Kasiviswanathan, Harish
@ 2024-04-10 21:08 ` Joshi, Mukul
  1 sibling, 0 replies; 3+ messages in thread
From: Joshi, Mukul @ 2024-04-10 21:08 UTC (permalink / raw)
  To: Kuehling, Felix, amd-gfx; +Cc: Chen, Xiaogang

[AMD Official Use Only - General]

> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Felix
> Kuehling
> Sent: Wednesday, April 10, 2024 4:05 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Chen, Xiaogang <Xiaogang.Chen@amd.com>
> Subject: [PATCH] drm/amdkfd: Fix memory leak in create_process failure
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Fix memory leak due to a leaked mmget reference on an error handling code
> path that is triggered when attempting to create KFD processes while a GPU
> reset is in progress.
>
> Fixes: 0ab2d7532b05 ("drm/amdkfd: prepare per-process debug enable and
> disable")
> CC: Xiaogang Chen <xiaogang.chen@amd.com>
> Signed-off-by: Felix Kuehling <felix.kuehling@amd.com>


Reviewed-by: Mukul Joshi <mukul.joshi@amd.com>

> ---
>  drivers/gpu/drm/amd/amdkfd/kfd_process.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> index 717a60d7a4ea..b79986412cd8 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> @@ -819,9 +819,9 @@ struct kfd_process *kfd_create_process(struct
> task_struct *thread)
>         mutex_lock(&kfd_processes_mutex);
>
>         if (kfd_is_locked()) {
> -               mutex_unlock(&kfd_processes_mutex);
>                 pr_debug("KFD is locked! Cannot create process");
> -               return ERR_PTR(-EINVAL);
> +               process = ERR_PTR(-EINVAL);
> +               goto out;
>         }
>
>         /* A prior open of /dev/kfd could have already created the process. */
> --
> 2.34.1


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

end of thread, other threads:[~2024-04-10 21:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-10 20:04 [PATCH] drm/amdkfd: Fix memory leak in create_process failure Felix Kuehling
2024-04-10 20:09 ` Kasiviswanathan, Harish
2024-04-10 21:08 ` Joshi, Mukul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.