Skip to contentSkip to conversation

drm/amd/pm: use kmemdup() rather than kmalloc+memcpy

PATCH Applied Alex Dewar 2 participants 2 messages Aug 24, 2020

Subsystems (3)
lore
Share & tools
lore

Alex Dewar

author
#0 lore raw

PATCH 1/1 drm/amd/pm: use kmemdup() rather than kmalloc+memcpy

Issue identified with Coccinelle.

---
 .../drm/amd/pm/powerplay/hwmgr/vega20_processpptables.c   | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_processpptables.c +3 -5
index f56a3cbdfa3b..1f9082539457 100644
@@ -890,14 +890,12 @@ static int init_powerplay_table_information(
 				power_saving_clock_count);
 	}
 
-	pptable_information->smc_pptable = kmalloc(sizeof(PPTable_t), GFP_KERNEL);
+	pptable_information->smc_pptable = kmemdup(&(powerplay_table->smcPPTable),
+						   sizeof(PPTable_t),
+						   GFP_KERNEL);
 	if (pptable_information->smc_pptable == NULL)
 		return -ENOMEM;
 
-	memcpy(pptable_information->smc_pptable,
-			&(powerplay_table->smcPPTable),
-			sizeof(PPTable_t));
-
 
 	result = append_vbios_pptable(hwmgr, (pptable_information->smc_pptable));
 	if (result)
Signature · 1 line
2.28.0
Applied
#1 lore raw

Applied. Thanks!

Alex

Quoted 33 lines · Alex Dewar

Issue identified with Coccinelle.

---
 .../drm/amd/pm/powerplay/hwmgr/vega20_processpptables.c   | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_processpptables.c +3 -6
index f56a3cbdfa3b..1f9082539457 100644
@@ -890,14 +890,12 @@ static int init_powerplay_table_information(
                                power_saving_clock_count);
        }
 
-       pptable_information->smc_pptable = kmalloc(sizeof(PPTable_t), GFP_KERNEL);
+       pptable_information->smc_pptable = kmemdup(&(powerplay_table->smcPPTable),
+                                                  sizeof(PPTable_t),
+                                                  GFP_KERNEL);
        if (pptable_information->smc_pptable == NULL)
                return -ENOMEM;
 
-       memcpy(pptable_information->smc_pptable,
-                       &(powerplay_table->smcPPTable),
-                       sizeof(PPTable_t));
-
 
        result = append_vbios_pptable(hwmgr, (pptable_information->smc_pptable));
        if (result)
--

2.28.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel