Skip to contentSkip to conversation

Fixes: 227942809b52 ("cpufreq: powernv: Restore cpu frequency to policy->cur on unthrottling")

PATCH In review Pratik Rajesh Sampat 2 participants 3 messages Mar 6, 2020 – Mar 16, 2020

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

PATCH 1/1 Fixes: 227942809b52 ("cpufreq: powernv: Restore cpu frequency to policy->cur on unthrottling")

The patch avoids allocating cpufreq_policy on stack hence fixing frame size overflow in 'powernv_cpufreq_work_fn'

---
 drivers/cpufreq/powernv-cpufreq.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/cpufreq/powernv-cpufreq.c +8 -5
index 56f4bc0d209e..20ee0661555a 100644
@@ -902,6 +902,7 @@ static struct notifier_block powernv_cpufreq_reboot_nb = {
 void powernv_cpufreq_work_fn(struct work_struct *work)
 {
 	struct chip *chip = container_of(work, struct chip, throttle);
+	struct cpufreq_policy *policy;
 	unsigned int cpu;
 	cpumask_t mask;
 
@@ -916,12 +917,14 @@ void powernv_cpufreq_work_fn(struct work_struct *work)
 	chip->restore = false;
 	for_each_cpu(cpu, &mask) {
 		int index;
-		struct cpufreq_policy policy;
 
-		cpufreq_get_policy(&policy, cpu);
-		index = cpufreq_table_find_index_c(&policy, policy.cur);
-		powernv_cpufreq_target_index(&policy, index);
-		cpumask_andnot(&mask, &mask, policy.cpus);
+		policy = cpufreq_cpu_get(cpu);
+		if (!policy)
+			continue;
+		index = cpufreq_table_find_index_c(policy, policy->cur);
+		powernv_cpufreq_target_index(policy, index);
+		cpumask_andnot(&mask, &mask, policy->cpus);
+		cpufreq_cpu_put(policy);
 	}
 out:
 	put_online_cpus();
Signature · 1 line
2.17.1
#1 lore raw

Hi Pratik,

Please could you resend this with a more meaningful subject line and move the Fixes: line to immediately above your signed-off-by?

Thanks!

Regards,
Daniel

Quoted 42 lines

The patch avoids allocating cpufreq_policy on stack hence fixing frame size overflow in 'powernv_cpufreq_work_fn'

---
 drivers/cpufreq/powernv-cpufreq.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/cpufreq/powernv-cpufreq.c +8 -5
index 56f4bc0d209e..20ee0661555a 100644
@@ -902,6 +902,7 @@ static struct notifier_block powernv_cpufreq_reboot_nb = {
 void powernv_cpufreq_work_fn(struct work_struct *work)
 {
 	struct chip *chip = container_of(work, struct chip, throttle);
+	struct cpufreq_policy *policy;
 	unsigned int cpu;
 	cpumask_t mask;
 
@@ -916,12 +917,14 @@ void powernv_cpufreq_work_fn(struct work_struct *work)
 	chip->restore = false;
 	for_each_cpu(cpu, &mask) {
 		int index;
-		struct cpufreq_policy policy;
 
-		cpufreq_get_policy(&policy, cpu);
-		index = cpufreq_table_find_index_c(&policy, policy.cur);
-		powernv_cpufreq_target_index(&policy, index);
-		cpumask_andnot(&mask, &mask, policy.cpus);
+		policy = cpufreq_cpu_get(cpu);
+		if (!policy)
+			continue;
+		index = cpufreq_table_find_index_c(policy, policy->cur);
+		powernv_cpufreq_target_index(policy, index);
+		cpumask_andnot(&mask, &mask, policy->cpus);
+		cpufreq_cpu_put(policy);
 	}
 out:
 	put_online_cpus();
Signature · 1 line
2.17.1
#2 lore raw

Hi Daniel,

Sure thing I'll re-send them. Rookie mistake, my bad. Thanks for pointing it out!

Regards,
Pratik

Quoted 52 lines · Daniel Axtens

Hi Pratik,

Please could you resend this with a more meaningful subject line and move the Fixes: line to immediately above your signed-off-by?

Thanks!

Regards,
Daniel

Quoted 42 lines

The patch avoids allocating cpufreq_policy on stack hence fixing frame size overflow in 'powernv_cpufreq_work_fn'

---
  drivers/cpufreq/powernv-cpufreq.c | 13 ++++++++-----
  1 file changed, 8 insertions(+), 5 deletions(-)
drivers/cpufreq/powernv-cpufreq.c +8 -5
index 56f4bc0d209e..20ee0661555a 100644
@@ -902,6 +902,7 @@ static struct notifier_block powernv_cpufreq_reboot_nb = {
  void powernv_cpufreq_work_fn(struct work_struct *work)
  {
  	struct chip *chip = container_of(work, struct chip, throttle);
+	struct cpufreq_policy *policy;
  	unsigned int cpu;
  	cpumask_t mask;
 
@@ -916,12 +917,14 @@ void powernv_cpufreq_work_fn(struct work_struct *work)
  	chip->restore = false;
  	for_each_cpu(cpu, &mask) {
  		int index;
-		struct cpufreq_policy policy;
 
-		cpufreq_get_policy(&policy, cpu);
-		index = cpufreq_table_find_index_c(&policy, policy.cur);
-		powernv_cpufreq_target_index(&policy, index);
-		cpumask_andnot(&mask, &mask, policy.cpus);
+		policy = cpufreq_cpu_get(cpu);
+		if (!policy)
+			continue;
+		index = cpufreq_table_find_index_c(policy, policy->cur);
+		powernv_cpufreq_target_index(policy, index);
+		cpumask_andnot(&mask, &mask, policy->cpus);
+		cpufreq_cpu_put(policy);
  	}
  out:
  	put_online_cpus();
Signature · 1 line
2.17.1