Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] thermal: devfreq_cooling: avoid unnecessary kfree of freq_table
@ 2026-03-23  9:40 Anas Iqbal
  2026-03-23 10:44 ` Lukasz Luba
  0 siblings, 1 reply; 3+ messages in thread
From: Anas Iqbal @ 2026-03-23  9:40 UTC (permalink / raw)
  To: rafael, daniel.lezcano
  Cc: rui.zhang, lukasz.luba, linux-pm, linux-kernel, Anas Iqbal

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.

Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>
---
 drivers/thermal/devfreq_cooling.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c
index 597e86d16a4e..1c7dffc8d45f 100644
--- a/drivers/thermal/devfreq_cooling.c
+++ b/drivers/thermal/devfreq_cooling.c
@@ -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);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-23 13:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23  9:40 [PATCH] thermal: devfreq_cooling: avoid unnecessary kfree of freq_table Anas Iqbal
2026-03-23 10:44 ` Lukasz Luba
2026-03-23 13:52   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox