Skip to content

Commit 746ea32

Browse files
fabocodefabiobaltieri
authored andcommitted
drivers: sensor: bosch: bme680: fix: possible overflowed value return value
- Check if value exceeds limits of the variable Signed-off-by: Fabian Barraez <[email protected]>
1 parent 6888aba commit 746ea32

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/sensor/bosch/bme680/bme680.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ static uint8_t bme680_calc_gas_wait(uint16_t dur)
207207
dur = dur / 4;
208208
factor += 1;
209209
}
210-
durval = dur + (factor * 64);
210+
const uint16_t max_duration = dur + (factor * 64);
211+
212+
durval = CLAMP(max_duration, 0, 0xff);
211213
}
212214

213215
return durval;

0 commit comments

Comments
 (0)