diff mbox series

drm/amdkfd: fix a potential double free in pqm_create_queue

Message ID 20230308001903.2841087-1-olvaffe@gmail.com (mailing list archive)
State New, archived
Headers show
Series drm/amdkfd: fix a potential double free in pqm_create_queue | expand

Commit Message

Chia-I Wu March 8, 2023, 12:19 a.m. UTC
Set *q to NULL on errors, otherwise pqm_create_queue would free it
again.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Felix Kuehling March 8, 2023, 5:42 p.m. UTC | #1
On 2023-03-07 19:19, Chia-I Wu wrote:
> Set *q to NULL on errors, otherwise pqm_create_queue would free it
> again.
>
> Signed-off-by: Chia-I Wu <olvaffe@gmail.com>

Thank you! I'm applying this patch to amd-staging-drm-next.

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


> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> 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 5137476ec18e6..4236539d9f932 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> @@ -218,8 +218,8 @@ static int init_user_queue(struct process_queue_manager *pqm,
>   	return 0;
>   
>   cleanup:
> -	if (dev->shared_resources.enable_mes)
> -		uninit_queue(*q);
> +	uninit_queue(*q);
> +	*q = NULL;
>   	return retval;
>   }
>
diff mbox series

Patch

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 5137476ec18e6..4236539d9f932 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
@@ -218,8 +218,8 @@  static int init_user_queue(struct process_queue_manager *pqm,
 	return 0;
 
 cleanup:
-	if (dev->shared_resources.enable_mes)
-		uninit_queue(*q);
+	uninit_queue(*q);
+	*q = NULL;
 	return retval;
 }