drm/amdkfd: Use kmemdup instead of duplicating its function
authorzhong jiang <zhongjiang@huawei.com>
Tue, 18 Sep 2018 15:35:32 +0000 (23:35 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 5 Nov 2018 19:20:36 +0000 (14:20 -0500)
kmemdup has implemented the function that kmalloc() + memcpy().
We prefer to kmemdup rather than code opened implementation.

Signed-off-by: zhong jiang <zhongjiang@huawei.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>
drivers/gpu/drm/amd/amdkfd/kfd_crat.c

index 56412b0e7e1c73d79ff2a701b5da7a54affb258a..dd4f3bdbf08cd88dd20db6c161f13572760bec58 100644 (file)
@@ -753,12 +753,10 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size)
                return -ENODATA;
        }
 
-       pcrat_image = kmalloc(crat_table->length, GFP_KERNEL);
+       pcrat_image = kmemdup(crat_table, crat_table->length, GFP_KERNEL);
        if (!pcrat_image)
                return -ENOMEM;
 
-       memcpy(pcrat_image, crat_table, crat_table->length);
-
        *crat_image = pcrat_image;
        *size = crat_table->length;