summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/dptf.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/common/dptf.c b/common/dptf.c
index b5d58d0846..c7623ce479 100644
--- a/common/dptf.c
+++ b/common/dptf.c
@@ -59,6 +59,11 @@ static int dptf_check_temp_threshold(int sensor_id, int temp)
int tripped = 0;
int max, i;
+ if (sensor_id >= TEMP_SENSOR_COUNT) {
+ CPRINTS("DPTF: Invalid sensor ID");
+ return 0;
+ }
+
for (i = 0; i < DPTF_THRESHOLDS_PER_SENSOR; i++) {
max = dptf_threshold[sensor_id][i].temp;
@@ -92,6 +97,12 @@ void dptf_set_temp_threshold(int sensor_id, int temp, int idx, int enable)
CPRINTS("DPTF sensor %d, threshold %d C, index %d, %sabled",
sensor_id, K_TO_C(temp), idx, enable ? "en" : "dis");
+ if ((sensor_id >= TEMP_SENSOR_COUNT) ||
+ (idx >= DPTF_THRESHOLDS_PER_SENSOR)) {
+ CPRINTS("DPTF: Invalid sensor ID");
+ return;
+ }
+
if (enable) {
/* Don't update threshold condition if already enabled */
if (dptf_threshold[sensor_id][idx].temp == -1)