drm/amdgpu/powerplay/psm: Fix memory leak in power state init
Subsystems (3)
PATCH 1/1 drm/amdgpu/powerplay/psm: Fix memory leak in power state init
Commit 902bc65de0b3 ("drm/amdgpu/powerplay/psm: return an error in power state init") made the power state init function return early in case of failure to get an entry from the powerplay table, but it missed to clean up the allocated memory for the current power state before returning.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +2 -0
@@ -75,8 +75,10 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr)for (i =0 ; i < table_entries; i++) { result = hwmgr->hwmgr_func->get_pp_table_entry (hwmgr, i, state);if (result) { +kfree (hwmgr->current_ps);kfree (hwmgr->request_ps);kfree (hwmgr->ps); + hwmgr->current_ps =NULL ; hwmgr->request_ps =NULL ; hwmgr->ps =NULL ;return -EINVAL ;
Signature · 1 line
2.34.1
[AMD Official Use Only - General]
Quoted 45 lines
-----Original Message-----
From: Rafael Mendonca <[email protected]>
Sent: Tuesday, October 18, 2022 8:54 AM
To: Quan, Evan <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>
Cc: Rafael Mendonca <[email protected]>; amd- [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH] drm/amdgpu/powerplay/psm: Fix memory leak in power state initCommit
902bc65de0b3("drm/amdgpu/powerplay/psm: return an error in power state init") made the power state init function return early in case of failure to get an entry from the powerplay table, but it missed to clean up the allocated memory for the current power state before returning.Fixes 902bc65de0b3 ("drm/amdgpu/powerplay/psm: return an error inpower state init")
Signed-off-by Rafael Mendonca <[email protected]>--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +2
-0@@ -75,8 +75,10 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr)for (i =0 ; i < table_entries; i++) { result = hwmgr->hwmgr_func->get_pp_table_entry (hwmgr, i, state);if (result) { +kfree (hwmgr->current_ps);kfree (hwmgr->request_ps);kfree (hwmgr->ps); + hwmgr->current_ps =NULL ; hwmgr->request_ps =NULL ;drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +0
-1hwmgr->ps =NULL ;return -EINVAL ; --2.34.1
Alex Deucher
AppliedApplied. Thanks!
Alex
Quoted 50 lines · Evan
[AMD Official Use Only - General]
Reviewed-by Evan Quan <[email protected]>Quoted 45 lines
-----Original Message-----
From: Rafael Mendonca <[email protected]>
Sent: Tuesday, October 18, 2022 8:54 AM
To: Quan, Evan <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>
Cc: Rafael Mendonca <[email protected]>; amd- [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH] drm/amdgpu/powerplay/psm: Fix memory leak in power state initCommit
902bc65de0b3("drm/amdgpu/powerplay/psm: return an error in power state init") made the power state init function return early in case of failure to get an entry from the powerplay table, but it missed to clean up the allocated memory for the current power state before returning.Fixes 902bc65de0b3 ("drm/amdgpu/powerplay/psm: return an error inpower state init")
Signed-off-by Rafael Mendonca <[email protected]>--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +2
-0@@ -75,8 +75,10 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr)for (i =0 ; i < table_entries; i++) { result = hwmgr->hwmgr_func->get_pp_table_entry (hwmgr, i, state);if (result) { +kfree (hwmgr->current_ps);kfree (hwmgr->request_ps);kfree (hwmgr->ps); + hwmgr->current_ps =NULL ; hwmgr->request_ps =NULL ;hwmgr->ps = NULL; return -EINVAL;--
2.34.1