sd.c: always pause clock after sdcard check
What changed, and why it matters
This commit fixes a bug in how the BitBox02 hardware wallet checks whether a microSD card is inserted. Previously, if a card was inserted, the device left the SD card clock running while retrying initialization, which could make the touchscreen less reliable. The fix moves the clock-pause command so it always runs after the check, even during retries. The changelog frames this as improving touch sensor reliability, not as a security fix.
Treat as a reliability/quality fix rather than a security patch. Review whether the running SD clock could have any security-relevant side effects, such as timing behavior, power-consumption patterns, or interference with other peripherals, but no immediate security action is indicated by the commit itself.
Security signals we found
Resource not released in all code paths (clock left running during retry loop)
Functional side effect on another subsystem (touch sensor reliability)
Vendor describes change as reliability improvement, not security vulnerability
Evidence from the diff
In src/sd.c, sd_card_inserted() calls sd_mmc_check(0) and, if it returns SD_MMC_INIT_ONGOING, loops up to 10 times waiting for initialization. The original code called sd_mmc_pause_clock() immediately after sd_mmc_check(0), before the retry loop. That meant the clock stayed unpaused throughout the retry loop when a card was present. The patch moves sd_mmc_pause_clock() to after the retry loop so the clock is always paused. The changelog describes the user-visible effect as improved touch-sensor reliability when an SD card is inserted.
Changed components
src/sd.cSD card detection/initialization routineTouch sensor subsystem (affected by clock state)Inspect captured patch +4 / −1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b7e00c3..444de74 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,9 @@ customers cannot upgrade their bootloader, its changes are recorded separately.
- Add API call to fetch multiple xpubs at once
- Add the option for the simulator to write its memory to file.
+### 9.23.2
+- Improve touch sensor reliability when the sdcard is inserted
+
### 9.23.1
- EVM: add HyperEVM (HYPE) and SONIC (S) to known networks
- U2F: fix macos/safari macos/firefox support
diff --git a/src/sd.c b/src/sd.c
index e5377f6..8d0462a 100644
--- a/src/sd.c
+++ b/src/sd.c
@@ -315,7 +315,6 @@ bool sd_card_inserted(void)
return true;
#else
sd_mmc_err_t err = sd_mmc_check(0);
- sd_mmc_pause_clock();
/* If initialization is ongoing, wait up to 1 second for it to initialize */
if (err == SD_MMC_INIT_ONGOING) {
for (int i = 0; i < 10; ++i) {
@@ -326,6 +325,7 @@ bool sd_card_inserted(void)
}
}
}
+ sd_mmc_pause_clock();
#if !defined(NDEBUG)
switch (err) {
case SD_MMC_OK:
Why this scored 30/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.