]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amdkfd: Fix a potential memory leak
authorOak Zeng <ozeng@amd.com>
Wed, 28 Nov 2018 04:08:25 +0000 (22:08 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Jul 2019 05:24:33 +0000 (07:24 +0200)
[ Upstream commit e73390d181103a19e1111ec2f25559a0570e9fe0 ]

Free mqd_mem_obj it GTT buffer allocation for MQD+control stack fails.

Signed-off-by: Oak Zeng <ozeng@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c

index 9dbba609450e73a7e2c4702bc7c3d59c1274cf01..8fe74b821b32b5383f9633c41ce319962e1ac7f4 100644 (file)
@@ -76,6 +76,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.
@@ -93,8 +94,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;