summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCandice Li <candice.li@amd.com>2026-05-20 12:14:37 +0800
committerAlex Deucher <alexander.deucher@amd.com>2026-06-03 13:53:03 -0400
commit05465e2a13f138258a0c77116fd8fd9f2f41952e (patch)
tree2f89a9482538346b3947d1502e1b99d0acd29167
parent66a856e3e5d92a09363dea37e9376921b30aaa6b (diff)
downloadlinux-05465e2a13f138258a0c77116fd8fd9f2f41952e.tar.gz
linux-05465e2a13f138258a0c77116fd8fd9f2f41952e.zip
drm/amd/pm: use kcalloc in phm table copy helpers
Use kcalloc() so multiplication overflow is detected and allocation fails safely for phm table copy helpers. Signed-off-by: Candice Li <candice.li@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.c
index 30d83e18db40..085b100821b9 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.c
@@ -49,11 +49,10 @@ int phm_copy_clock_limits_array(
const uint32_t *pptable_array,
uint32_t power_saving_clock_count)
{
- uint32_t array_size, i;
+ uint32_t i;
uint32_t *table;
- array_size = sizeof(uint32_t) * power_saving_clock_count;
- table = kzalloc(array_size, GFP_KERNEL);
+ table = kcalloc(power_saving_clock_count, sizeof(uint32_t), GFP_KERNEL);
if (NULL == table)
return -ENOMEM;
@@ -71,11 +70,10 @@ int phm_copy_overdrive_settings_limits_array(
const uint32_t *pptable_array,
uint32_t od_setting_count)
{
- uint32_t array_size, i;
+ uint32_t i;
uint32_t *table;
- array_size = sizeof(uint32_t) * od_setting_count;
- table = kzalloc(array_size, GFP_KERNEL);
+ table = kcalloc(od_setting_count, sizeof(uint32_t), GFP_KERNEL);
if (NULL == table)
return -ENOMEM;