xiaoxiang781216 commented on code in PR #17263:
URL: https://github.com/apache/nuttx/pull/17263#discussion_r2481295945


##########
sched/signal/sig_dispatch.c:
##########
@@ -485,7 +500,11 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t 
*info,
    * needs to be done here before using the task state or sigprocmask.
    */
 
-  flags = nxsig_alloc_dyn_pending(flags);

Review Comment:
   ```
   ret = nxsig_alloc_dyn_pending(&flags);
   if (ret < 0)
     {
       leave_critical_section(flags);
       return ret;
     }
   ```



##########
sched/signal/sig_dispatch.c:
##########
@@ -357,61 +357,76 @@ static FAR sigpendq_t *nxsig_add_pendingsignal(FAR struct 
tcb_s *stcb,
  *
  ****************************************************************************/
 
-static irqstate_t nxsig_alloc_dyn_pending(irqstate_t flags)
+static int nxsig_alloc_dyn_pending(irqstate_t *flags)

Review Comment:
   ```suggestion
   static int nxsig_alloc_dyn_pending(FAR irqstate_t *flags)
   ```



##########
sched/signal/sig_dispatch.c:
##########
@@ -357,61 +357,76 @@ static FAR sigpendq_t *nxsig_add_pendingsignal(FAR struct 
tcb_s *stcb,
  *
  ****************************************************************************/
 
-static irqstate_t nxsig_alloc_dyn_pending(irqstate_t flags)
+static int nxsig_alloc_dyn_pending(irqstate_t *flags)
 {
-  if (!up_interrupt_context())
-    {
-      bool alloc_signal = sq_empty(&g_sigpendingsignal);
-      bool alloc_sigact = sq_empty(&g_sigpendingaction);
+  int ret = OK;
+  bool alloc_signal = sq_empty(&g_sigpendingsignal);
+  bool alloc_sigact = sq_empty(&g_sigpendingaction);
 
-      /* Signals are not dispatched from the idle task */
+  if (alloc_signal || alloc_sigact)
+    {
+      FAR sigpendq_t *sigpend = NULL;
+      FAR sigq_t *sigq = NULL;
 
-      DEBUGASSERT(!sched_idletask());
+      /* We can't do memory allocations in idle task or interrupt */
 
-      if (alloc_signal || alloc_sigact)
+      if (up_interrupt_context() || sched_idletask())
         {
-          FAR sigpendq_t *sigpend = NULL;
-          FAR sigq_t *sigq = NULL;
+          return -ENOMEM;

Review Comment:
   let's change all error code to -EAGAIN



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to