Repository navigation
arch/xtensa/esp32: fix double spinlock unlock in esp32_txint - #20769
Merged
acassis merged 1 commit intoOct 18, 2026
Merged
Conversation
In esp32_txint(), when CONFIG_SUPPRESS_SERIAL_INTS was enabled, spin_unlock_irqrestore(&priv->lock, flags) was invoked inside the if (enable) block before calling uart_xmitchars(dev), and then called a second time unconditionally after the if/else block. Restructure esp32_txint() so that the spinlock is released exactly once across all execution paths, and call uart_xmitchars(dev) safely after releasing priv->lock to prevent recursive deadlocks. Resolves apache#14594. Signed-off-by: Swatantra Yadav <[email protected]>
Swatantra-66
force-pushed
the
fix/esp32-serial-double-unlock
branch
from
October 18, 2026 09:14
fcd1f2b to
59fa92a
Compare
xiaoxiang781216
approved these changes
Oct 18, 2026
acassis
approved these changes
Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #14594.
In
esp32_txint()(arch/xtensa/src/esp32/esp32_serial.c), whenCONFIG_SUPPRESS_SERIAL_INTSwas active,spin_unlock_irqrestore(&priv->lock, flags)was called inside theif (enable)block before invokinguart_xmitchars(dev). The execution then exited theif (enable)block and hit an unconditionalspin_unlock_irqrestore(&priv->lock, flags)at the bottom of the function, causing consecutive unlocks on the same lock (issue #14594).This PR restructures
esp32_txint()so that:if (enable)andelsebranches and released exactly once at the end of the critical section.CONFIG_SUPPRESS_SERIAL_INTS,uart_xmitchars(dev)is called safely afterpriv->lockis released, preventing recursive spinlock deadlocks whenuart_xmitcharscalls back intotxint(dev, false).uart_xmitchars()runs after the spinlock is released.Impact
Testing
./tools/checkpatch.sh -u HEAD(0 errors, 0 warnings)../tools/nxstyleonarch/xtensa/src/esp32/esp32_serial.c(0 errors, 0 warnings).