summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2019-07-31 10:41:58 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2019-07-31 10:41:58 +0000
commit27fc73761c9578780d851508512e9ebabf4d7d70 (patch)
tree554aae48f76e7c7ed52f4c601fab48d79e120202 /sys
parent7338326b62dccb3f94e32fdb141aa94c83ab87ff (diff)
drm/amdkfd: Fix a potential memory leak
From Oak Zeng db64bc13944013357d231cbf9d1aee798d7b9892 in linux 4.19.y/4.19.63 e73390d181103a19e1111ec2f25559a0570e9fe0 in mainline linux
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/amd/amdkfd/kfd_mqd_manager_v9.c5
1 files changed, 4 insertions, 1 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 f88191df037..2ffe467a1d1 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
@@ -75,6 +75,7 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,
struct v9_mqd *m;
struct kfd_dev *kfd = mm->dev;
+ *mqd_mem_obj = NULL;
/* From V9, for CWSR, the control stack is located on the next page
* boundary after the mqd, we will use the gtt allocation function
* instead of sub-allocation function.
@@ -92,8 +93,10 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,
} else
retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct v9_mqd),
mqd_mem_obj);
- if (retval != 0)
+ if (retval) {
+ kfree(*mqd_mem_obj);
return -ENOMEM;
+ }
m = (struct v9_mqd *) (*mqd_mem_obj)->cpu_ptr;
addr = (*mqd_mem_obj)->gpu_addr;