Skip to content

Commit 479a220

Browse files
committed
fwk: Check parameter in get_hardware_id
BUG=Leila found that if you call this function with an invalid adc channel, the EC crashes. TEST=See bug BRANCH=fwk-main Signed-off-by: Daniel Schaefer <[email protected]> (cherry picked from commit c63e94ff8f3b97aec660b9aae03a90ac9f82998d)
1 parent f996201 commit 479a220

File tree

1 file changed

+3
-0
lines changed
  • zephyr/program/framework/src

1 file changed

+3
-0
lines changed

zephyr/program/framework/src/adc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ enum board_version_t get_hardware_id(enum adc_channel channel)
6868
int mv;
6969
int i;
7070

71+
if (channel >= ADC_CH_COUNT)
72+
return BOARD_VERSION_UNKNOWN;
73+
7174
mv = adc_read_channel(channel);
7275

7376
if (mv < 0) {

0 commit comments

Comments
 (0)