chore(core): replace U5 specific HAL macro with more universal in tamper driver
What changed, and why it matters
This is a one-line code cleanup in Trezor's tamper-detection driver for STM32U5 chips. It swaps an STM32-specific macro that checks whether the power clock is disabled for the equivalent macro that checks whether it is enabled, adding a logical NOT. The behavior is identical; there is no security fix or functional change.
No security action required; treat as normal refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change replaces __HAL_RCC_PWR_IS_CLK_DISABLED() with !__HAL_RCC_PWR_IS_CLK_ENABLED() in core/embed/sec/tamper/stm32u5/tamper.c. Both macros are standard STM32 HAL definitions evaluating the same RCC register bit; the new form is more portable across STM32 families. The conditional logic and resulting clock enablement remain unchanged.
Changed components
core/embed/sec/tamper/stm32u5/tamper.cInspect captured patch +1 / −1
diff --git a/core/embed/sec/tamper/stm32u5/tamper.c b/core/embed/sec/tamper/stm32u5/tamper.c
index 5bbc1918..edd74797 100644
--- a/core/embed/sec/tamper/stm32u5/tamper.c
+++ b/core/embed/sec/tamper/stm32u5/tamper.c
@@ -46,7 +46,7 @@ static HAL_StatusTypeDef clk_init(uint32_t source) {
bool pwrclkchanged = false;
// Enable Power Clock
- if (__HAL_RCC_PWR_IS_CLK_DISABLED()) {
+ if (!__HAL_RCC_PWR_IS_CLK_ENABLED()) {
__HAL_RCC_PWR_CLK_ENABLE();
pwrclkchanged = true;
}
Why this scored 15/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.