summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2018-12-31 18:00:53 +0000
committerkettenis <kettenis@openbsd.org>2018-12-31 18:00:53 +0000
commit67d89b537903ba243ac148a3ee5e18e7d58aa404 (patch)
tree76f8102f2e112f61a44ee9cdae819bab950be80a
parentUse the return value of task_add(9) to determine whether the task was (diff)
downloadwireguard-openbsd-67d89b537903ba243ac148a3ee5e18e7d58aa404.tar.xz
wireguard-openbsd-67d89b537903ba243ac148a3ee5e18e7d58aa404.zip
Avoid calling setperf() with a negative level.
Avoid a potential use of an unitilized variable to pick an operating point. Remove an unused (but set) variable. ok patrick@
-rw-r--r--sys/arch/arm64/arm64/cpu.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/sys/arch/arm64/arm64/cpu.c b/sys/arch/arm64/arm64/cpu.c
index 539259d6195..42d440c2b6c 100644
--- a/sys/arch/arm64/arm64/cpu.c
+++ b/sys/arch/arm64/arm64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.24 2018/08/25 20:45:28 kettenis Exp $ */
+/* $OpenBSD: cpu.c,v 1.25 2018/12/31 18:00:53 kettenis Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
@@ -730,7 +730,7 @@ cpu_opp_mountroot(struct device *self)
cpu_setperf = cpu_opp_setperf;
perflevel = (level > 0) ? level : 0;
- cpu_setperf(level);
+ cpu_setperf(perflevel);
}
}
@@ -786,8 +786,7 @@ cpu_opp_setperf(int level)
struct opp_table *ot = ci->ci_opp_table;
uint64_t min, max;
uint64_t level_hz, opp_hz;
- uint32_t opp_microvolt;
- int opp_idx;
+ int opp_idx = -1;
int i;
if (ot == NULL)
@@ -803,10 +802,15 @@ cpu_opp_setperf(int level)
opp_hz = min;
for (i = 0; i < ot->ot_nopp; i++) {
if (ot->ot_opp[i].opp_hz <= level_hz &&
- ot->ot_opp[i].opp_hz >= opp_hz) {
+ ot->ot_opp[i].opp_hz >= opp_hz)
opp_hz = ot->ot_opp[i].opp_hz;
- opp_microvolt = ot->ot_opp[i].opp_microvolt;
+ }
+
+ /* Find index of selected operating point. */
+ for (i = 0; i < ot->ot_nopp; i++) {
+ if (ot->ot_opp[i].opp_hz == opp_hz) {
opp_idx = i;
+ break;
}
}
KASSERT(opp_idx >= 0);