Thread (9 messages) 9 messages, 2 authors, 2020-09-01
STALE2109d
Revisions (5)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v3 [diff vs current]
  4. v4 current
  5. v5 [diff vs current]

[PATCH v4 1/5] arch_topology: validate input frequencies to arch_set_freq_scale()

From: Ionela Voinescu <hidden>
Date: 2020-08-28 17:33:58
Also in: linux-pm, lkml
Subsystem: driver core, kobjects, debugfs and sysfs, generic architecture topology, the rest · Maintainers: Greg Kroah-Hartman, "Rafael J. Wysocki", Danilo Krummrich, Sudeep Holla, Linus Torvalds

The current frequency passed to arch_set_freq_scale() could end up
being 0, signaling an error in setting a new frequency. Also, if the
maximum frequency in 0, this will result in a division by 0 error.

Therefore, validate these input values before using them for the
setting of the frequency scale factor.

Signed-off-by: Ionela Voinescu <redacted>
Cc: Sudeep Holla <redacted>
Cc: Rafael J. Wysocki <redacted>
---
 drivers/base/arch_topology.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 75f72d684294..5708eb724790 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -33,6 +33,11 @@ void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq,
 	unsigned long scale;
 	int i;
 
+	if (unlikely(!cur_freq || !max_freq)) {
+		WARN_ON_ONCE(1);
+		return;
+	}
+
 	/*
 	 * If the use of counters for FIE is enabled, just return as we don't
 	 * want to update the scale factor with information from CPUFREQ.
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help