thermal: devfreq_cooling: avoid unnecessary kfree of freq_table
PATCH 1/1 thermal: devfreq_cooling: avoid unnecessary kfree of freq_table
dfc->freq_table is only allocated in the non-EM path via devfreq_cooling_gen_tables(). In the EM path, it remains NULL.
Avoid calling kfree() unnecessarily when freq_table was never allocated.
This resolves a Smatch warning:
calling kfree() when 'dfc->freq_table' is always NULL.
--- drivers/thermal/devfreq_cooling.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/devfreq_cooling.c +2 -1
@@ -472,7 +472,8 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df, remove_qos_req:dev_pm_qos_remove_request (&dfc->req_max_freq); free_table: -kfree (dfc->freq_table); +if (!dfc->em_pd) +kfree (dfc->freq_table); free_dfc:kfree (dfc);
Signature · 1 line
2.43.0
Quoted 18 lines · Anas Iqbal
dfc->freq_tableis only allocated in the non-EM path viadevfreq_cooling_gen_tables(). In the EM path, it remains NULL.Avoid calling
kfree()unnecessarily whenfreq_tablewas never allocated.This resolves a Smatch warning:
callingkfree()when 'dfc->freq_table' is always NULL.Signed-off-by Anas Iqbal <[email protected]>--- drivers/thermal/devfreq_cooling.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/thermal/devfreq_cooling.c +0
-0
drivers/thermal/devfreq_cooling.c of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df, · line 479
Quoted 9 lines
drivers/thermal/devfreq_cooling.c +2
-1@@ -472,7 +472,8 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df, remove_qos_req:dev_pm_qos_remove_request (&dfc->req_max_freq); free_table: -kfree (dfc->freq_table); +if (!dfc->em_pd) +kfree (dfc->freq_table); free_dfc:kfree (dfc);
LGTM, let's calm down that warning.
Quoted 34 lines · Lukasz Luba
Quoted 18 lines · Anas Iqbal
dfc->freq_tableis only allocated in the non-EM path viadevfreq_cooling_gen_tables(). In the EM path, it remains NULL.Avoid calling
kfree()unnecessarily whenfreq_tablewas never allocated.This resolves a Smatch warning:
callingkfree()when 'dfc->freq_table' is always NULL.Signed-off-by Anas Iqbal <[email protected]>--- drivers/thermal/devfreq_cooling.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/thermal/devfreq_cooling.c +0
-0drivers/thermal/devfreq_cooling.c of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df, · line 479
Quoted 9 lines
drivers/thermal/devfreq_cooling.c +2
-1@@ -472,7 +472,8 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df, remove_qos_req:dev_pm_qos_remove_request (&dfc->req_max_freq); free_table: -kfree (dfc->freq_table); +if (!dfc->em_pd) +kfree (dfc->freq_table); free_dfc:kfree (dfc);LGTM, let's calm down that warning.
Quoted 1 line
Reviewed-by Lukasz Luba <[email protected]>
Applied as 7.1 material, thanks!