Skip to content

Commit 42c816e

Browse files
committed
portio: Don't segfault if ioperm failed
Have to return and never try again Signed-off-by: Daniel Schaefer <[email protected]>
1 parent 056ec31 commit 42c816e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

framework_lib/src/chromium_ec/portio.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ fn init() -> bool {
100100
}
101101

102102
// First try on MEC
103-
portio_mec::init();
103+
if !portio_mec::init() {
104+
*init = Initialized::Failed;
105+
return false;
106+
}
104107
let ec_id = portio_mec::transfer_read(MEC_MEMMAP_OFFSET + EC_MEMMAP_ID, 2);
105108
if ec_id[0] == b'E' && ec_id[1] == b'C' {
106109
*init = Initialized::SucceededMec;
@@ -113,6 +116,7 @@ fn init() -> bool {
113116
let res = ioperm(EC_LPC_ADDR_HOST_ARGS as u64, 8 + 0xFF, 1);
114117
if res != 0 {
115118
error!("ioperm failed. portio driver is likely block by Linux kernel lockdown mode");
119+
*init = Initialized::Failed;
116120
return false;
117121
}
118122

0 commit comments

Comments
 (0)