Skip to contentSkip to conversation

PM: energy_model: Replace kfree() with em_table_free()

PATCH In review Kaushlendra Kumar 3 participants 3 messages Oct 13, 2025 – Oct 14, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM: energy_model: Replace kfree() with em_table_free()

Replace kfree() with em_table_free() for error path of em_create_pd() to ensure proper cleanup of energy model tables. The em_table_free() function provides the correct deallocation mechanism for energy model table structures, ensuring consistent memory management throughout the energy model subsystem.

---
 kernel/power/energy_model.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/energy_model.c +1 -1
index 5f17d2e8e954..e8ae1f518b8a 100644
@@ -441,7 +441,7 @@ static int em_create_pd(struct device *dev, int nr_states,
 	return 0;
 
 free_pd_table:
-	kfree(em_table);
+	em_table_free(em_table);
 free_pd:
 	kfree(pd);
 	return -EINVAL;
Signature · 1 line
2.34.1
#1 lore raw
Quoted 16 lines · Kaushlendra Kumar

Replace kfree() with em_table_free() for error path of em_create_pd() to ensure proper cleanup of energy model tables. The em_table_free() function provides the correct deallocation mechanism for energy model table structures, ensuring consistent memory management throughout the energy model subsystem.

---
 kernel/power/energy_model.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/energy_model.c +0 -0
index 5f17d2e8e954..e8ae1f518b8a 100644

kernel/power/energy_model.c static int em_create_pd(struct device *dev, int nr_states, · line 447

Quoted 8 lines
kernel/power/energy_model.c +1 -1
@@ -441,7 +441,7 @@ static int em_create_pd(struct device *dev, int nr_states,
 	return 0;
 
 free_pd_table:
-	kfree(em_table);
+	em_table_free(em_table);
 free_pd:
 	kfree(pd);
 	return -EINVAL;

I guess this could carry the fixes tag as well.

maintainer
#2 lore raw
Quoted 19 lines · Christian Loehle
Quoted 18 lines · Kaushlendra Kumar

Replace kfree() with em_table_free() for error path of em_create_pd() to ensure proper cleanup of energy model tables. The em_table_free() function provides the correct deallocation mechanism for energy model table structures, ensuring consistent memory management throughout the energy model subsystem.

---
  kernel/power/energy_model.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/energy_model.c +0 -0
index 5f17d2e8e954..e8ae1f518b8a 100644
@@ -441,7 +441,7 @@ static int em_create_pd(struct device *dev, int nr_states,
  	return 0;
 
Quoted 8 lines

kernel/power/energy_model.c static int em_create_pd(struct device *dev, int nr_states, · line 447

Quoted 6 lines
kernel/power/energy_model.c +1 -1
  free_pd_table:
-	kfree(em_table);
+	em_table_free(em_table);
  free_pd:
  	kfree(pd);
  	return -EINVAL;

I guess this could carry the fixes tag as well.

It was already discussed with NACK, which still holds.

https://lore.kernel.org/lkml/[email protected]/