mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
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>
This commit is contained in:
parent
66a856e3e5
commit
05465e2a13
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user