* [PATCH] drm/amd/pm: Use kmemdup instead of kmalloc and memcpy
@ 2020-11-10 11:34 Tian Tao
2020-11-10 17:08 ` Alex Deucher
0 siblings, 1 reply; 2+ messages in thread
From: Tian Tao @ 2020-11-10 11:34 UTC (permalink / raw)
To: evan.quan, alexander.deucher, christian.koenig, airlied, daniel,
alex.dewar90, nirmoy.das, amd-gfx, dri-devel, linux-kernel
Fixes coccicheck warning:
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c:255:
36-43: WARNING opportunity for kmemdup
Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
---
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c
index 740e2fc..1e79baa 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c
@@ -252,12 +252,11 @@ static int init_powerplay_table_information(
phm_copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_max, powerplay_table->PowerSavingClockMax, ATOM_VEGA12_PPCLOCK_COUNT);
phm_copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_min, powerplay_table->PowerSavingClockMin, ATOM_VEGA12_PPCLOCK_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));
return result;
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/amd/pm: Use kmemdup instead of kmalloc and memcpy
2020-11-10 11:34 [PATCH] drm/amd/pm: Use kmemdup instead of kmalloc and memcpy Tian Tao
@ 2020-11-10 17:08 ` Alex Deucher
0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2020-11-10 17:08 UTC (permalink / raw)
To: Tian Tao
Cc: Quan, Evan, Deucher, Alexander, Christian Koenig, Dave Airlie,
Daniel Vetter, Alex Dewar, Nirmoy Das, amd-gfx list,
Maling list - DRI developers, LKML
On Tue, Nov 10, 2020 at 11:57 AM Tian Tao <tiantao6@hisilicon.com> wrote:
>
> Fixes coccicheck warning:
> drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c:255:
> 36-43: WARNING opportunity for kmemdup
>
> Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Applied. Thanks!
Alex
> ---
> drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c
> index 740e2fc..1e79baa 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c
> @@ -252,12 +252,11 @@ static int init_powerplay_table_information(
> phm_copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_max, powerplay_table->PowerSavingClockMax, ATOM_VEGA12_PPCLOCK_COUNT);
> phm_copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_min, powerplay_table->PowerSavingClockMin, ATOM_VEGA12_PPCLOCK_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));
>
> return result;
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-10 17:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10 11:34 [PATCH] drm/amd/pm: Use kmemdup instead of kmalloc and memcpy Tian Tao
2020-11-10 17:08 ` Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).