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
commit 3b6f463ce2b54d1934e4357b4ea1d81635161c95 Author: chenrun1 <chenr...@xiaomi.com> AuthorDate: Tue Dec 31 14:31:46 2024 +0800 syslog_inbuffer:Fixed the lock reentry issue in single core + spinlock scenario Summary: When spinlock.h is enabled in a single-core scenario, spinlock reentry and exceptions may occur when spin_lock_irqsave_wo_note is used in syslog_add_intbuffer Signed-off-by: chenrun1 <chenr...@xiaomi.com> --- drivers/syslog/syslog_intbuffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/syslog/syslog_intbuffer.c b/drivers/syslog/syslog_intbuffer.c index d874819d4e..beaef2b107 100644 --- a/drivers/syslog/syslog_intbuffer.c +++ b/drivers/syslog/syslog_intbuffer.c @@ -104,8 +104,6 @@ static void syslog_flush_internal(bool force, size_t buflen) * concurrent modification by other tasks. */ - flags = spin_lock_irqsave_wo_note(&g_syslog_intbuffer.splock); - do { buffer = circbuf_get_readptr(&g_syslog_intbuffer.circ, &size); @@ -118,8 +116,6 @@ static void syslog_flush_internal(bool force, size_t buflen) } } while (size > 0 && buflen > 0); - - spin_unlock_irqrestore_wo_note(&g_syslog_intbuffer.splock, flags); } /**************************************************************************** @@ -201,7 +197,11 @@ void syslog_add_intbuffer(FAR const char *buffer, size_t buflen) void syslog_flush_intbuffer(bool force) { + irqstate_t flags; + + flags = spin_lock_irqsave_wo_note(&g_syslog_intbuffer.splock); syslog_flush_internal(force, sizeof(g_syslog_intbuffer.buffer)); + spin_unlock_irqrestore_wo_note(&g_syslog_intbuffer.splock, flags); } #endif /* CONFIG_SYSLOG_INTBUFFER */