drm/amdkfd: Fix potential deallocation of previously deallocated memory.
authorjsg <jsg@openbsd.org>
Thu, 20 Jul 2023 08:40:29 +0000 (08:40 +0000)
committerjsg <jsg@openbsd.org>
Thu, 20 Jul 2023 08:40:29 +0000 (08:40 +0000)
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

index afa246c..0600282 100644 (file)
@@ -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,