This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 7444a3c0b1aef317f4be4d8ae5b3535957f44f00
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Nov 3 14:28:21 2026 +0100

    sched/mqueue: Do not overfill a System V message queue from an interrupt.
    
    msgsnd() in an interrupt handler with a full queue and without
    IPC_NOWAIT added the message anyway, beyond the limit of the queue.
    An interrupt handler cannot wait, so give EAGAIN, as mq_send() does.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 sched/mqueue/msgsnd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sched/mqueue/msgsnd.c b/sched/mqueue/msgsnd.c
index a216b5afa56..5120fddbeac 100644
--- a/sched/mqueue/msgsnd.c
+++ b/sched/mqueue/msgsnd.c
@@ -197,14 +197,16 @@ int msgsnd(int msqid, FAR const void *msgp, size_t msgsz, 
int msgflg)
     {
       if (!up_interrupt_context()) /* In an interrupt handler? */
         {
-          /* Yes.. the message queue is full.  Wait for space to become
+          /* No.. the message queue is full.  Wait for space to become
            * available in the message queue.
            */
 
           ret = msgsnd_wait(msgq, msgsz, msgflg);
         }
-      else if ((msgflg & IPC_NOWAIT) != 0)
+      else
         {
+          /* Yes.. an interrupt handler cannot wait */
+
           ret = -EAGAIN;
         }
     }

Reply via email to