This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new d1fababfc5 arch/xtensa: esp32(s3)_async_op() using nxsem_wait(),
threads may return early due to signal interruption (EINTR). This makes the
main thread think the async operation is done, but the background worker thread
is still running—risking access to freed memory, race conditions, crashes or
undefined behavior.
d1fababfc5 is described below
commit d1fababfc5e4cc2221adb04bece89809024a55f2
Author: nuttxs <[email protected]>
AuthorDate: Fri Jul 18 17:54:04 2025 +0800
arch/xtensa: esp32(s3)_async_op() using nxsem_wait(), threads may
return early due to signal interruption (EINTR). This makes the
main thread think the async operation is done, but the background
worker thread is still running—risking access to freed memory,
race conditions, crashes or undefined behavior.
Using nxsem_wait_uninterruptible():the main thread waits until the
worker thread finishes, preventing these issues.
Signed-off-by: nuttxs <[email protected]>
---
arch/xtensa/src/esp32/esp32_spiflash.c | 2 +-
arch/xtensa/src/esp32s3/esp32s3_spiflash_mtd.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/xtensa/src/esp32/esp32_spiflash.c
b/arch/xtensa/src/esp32/esp32_spiflash.c
index 9622fc77bf..a1d5f06284 100644
--- a/arch/xtensa/src/esp32/esp32_spiflash.c
+++ b/arch/xtensa/src/esp32/esp32_spiflash.c
@@ -1732,7 +1732,7 @@ static int esp32_async_op(enum spiflash_op_code_e opcode,
ret = work_queue(LPWORK, &g_work, esp32_spiflash_work, &work_arg, 0);
if (ret == 0)
{
- nxsem_wait(&work_arg.sem);
+ nxsem_wait_uninterruptible(&work_arg.sem);
ret = work_arg.ret;
}
diff --git a/arch/xtensa/src/esp32s3/esp32s3_spiflash_mtd.c
b/arch/xtensa/src/esp32s3/esp32s3_spiflash_mtd.c
index ab0a0d596c..2e58fbf9d8 100644
--- a/arch/xtensa/src/esp32s3/esp32s3_spiflash_mtd.c
+++ b/arch/xtensa/src/esp32s3/esp32s3_spiflash_mtd.c
@@ -857,7 +857,7 @@ static int esp32s3_async_op(enum spiflash_op_code_e opcode,
ret = work_queue(LPWORK, &g_work, esp32s3_spiflash_work, &work_arg, 0);
if (ret == 0)
{
- nxsem_wait(&work_arg.sem);
+ nxsem_wait_uninterruptible(&work_arg.sem);
ret = work_arg.ret;
}