From 366ac040f8ce41829fce66768af7456e66e06416 Mon Sep 17 00:00:00 2001 From: jsg Date: Thu, 20 Jul 2023 08:40:29 +0000 Subject: [PATCH] drm/amdkfd: Fix potential deallocation of previously deallocated memory. From Daniil Dulov fabadad9e28dabecf25ad3c947aa8ba5f2b0eecf in linux-6.1.y/6.1.39 cabbdea1f1861098991768d7bbf5a49ed1608213 in mainline linux --- sys/dev/pci/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/dev/pci/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/sys/dev/pci/drm/amd/amdkfd/kfd_mqd_manager_v9.c index afa246cf9bc..06002825a94 100644 --- a/sys/dev/pci/drm/amd/amdkfd/kfd_mqd_manager_v9.c +++ b/sys/dev/pci/drm/amd/amdkfd/kfd_mqd_manager_v9.c @@ -115,18 +115,19 @@ static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd, &(mqd_mem_obj->gtt_mem), &(mqd_mem_obj->gpu_addr), (void *)&(mqd_mem_obj->cpu_ptr), true); + + if (retval) { + kfree(mqd_mem_obj); + return NULL; + } } else { retval = kfd_gtt_sa_allocate(kfd, sizeof(struct v9_mqd), &mqd_mem_obj); - } - - if (retval) { - kfree(mqd_mem_obj); - return NULL; + if (retval) + return NULL; } return mqd_mem_obj; - } static void init_mqd(struct mqd_manager *mm, void **mqd, -- 2.20.1