From fb998468b52bce596726899ce4e8e775e69877ec Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 28 Feb 2026 15:01:12 -1000 Subject: [PATCH] Fix comment about function calls and initialize ipsr - Update ISR safety comment: point 3 now reflects that wake_loop_any_context() is called (ISR-safe) - Initialize ipsr = 0 as safety net before inline asm --- esphome/core/component.cpp | 2 +- esphome/core/lwip_fast_select.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/core/component.cpp b/esphome/core/component.cpp index c8875f0705..0154bd6735 100644 --- a/esphome/core/component.cpp +++ b/esphome/core/component.cpp @@ -315,7 +315,7 @@ void IRAM_ATTR HOT Component::enable_loop_soon_any_context() { // This method is thread and ISR-safe because: // 1. Only performs simple assignments to volatile variables (atomic on all platforms) // 2. No read-modify-write operations that could be interrupted - // 3. No memory allocation, object construction, or function calls + // 3. No memory allocation or object construction; the only call (wake_loop_any_context) is ISR-safe // 4. IRAM_ATTR ensures code is in IRAM, not flash (required for ISR execution) // 5. Components are never destroyed, so no use-after-free concerns // 6. App is guaranteed to be initialized before any ISR could fire diff --git a/esphome/core/lwip_fast_select.c b/esphome/core/lwip_fast_select.c index 370638a8e0..63a58b71e6 100644 --- a/esphome/core/lwip_fast_select.c +++ b/esphome/core/lwip_fast_select.c @@ -247,7 +247,7 @@ void IRAM_ATTR esphome_lwip_wake_main_loop_from_isr(int *px_higher_priority_task // Avoids depending on CMSIS __get_IPSR() which may not be declared/available // in all LibreTiny chip family toolchains (e.g. beken-72xx). static inline uint32_t esphome_get_ipsr(void) { - uint32_t ipsr; + uint32_t ipsr = 0; __asm volatile("mrs %0, ipsr" : "=r"(ipsr)); return ipsr; }