drm/amd/powerplay/hwmgr: use kmemdup
authorMuhammad Falak R Wani <falakreyaz@gmail.com>
Thu, 19 May 2016 11:15:29 +0000 (16:45 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 19 May 2016 15:00:33 +0000 (11:00 -0400)
Use kmemdup when some other buffer is immediately copied into allocated
region. It replaces call to allocation followed by memcpy, by a single
call to kmemdup.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c

index 7c3f82b29402621ecfa494507502e2ab2ea31e00..16fed487973b9bd28396d109ba079086b127379c 100644 (file)
@@ -6056,11 +6056,11 @@ static int tonga_get_pp_table(struct pp_hwmgr *hwmgr, char **table)
        struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
 
        if (!data->soft_pp_table) {
-               data->soft_pp_table = kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL);
+               data->soft_pp_table = kmemdup(hwmgr->soft_pp_table,
+                                             hwmgr->soft_pp_table_size,
+                                             GFP_KERNEL);
                if (!data->soft_pp_table)
                        return -ENOMEM;
-               memcpy(data->soft_pp_table, hwmgr->soft_pp_table,
-                               hwmgr->soft_pp_table_size);
        }
 
        *table = (char *)&data->soft_pp_table;