Fix-Point commented on code in PR #17573:
URL: https://github.com/apache/nuttx/pull/17573#discussion_r2654927629


##########
sched/hrtimer/hrtimer_process.c:
##########
@@ -99,28 +98,70 @@ void hrtimer_process(uint64_t now)
       DEBUGASSERT(hrtimer->func != NULL);
 
       hrtimer->state = HRTIMER_STATE_RUNNING;
+      hrtimer->cpus++;
 
-      spin_unlock_irqrestore(&g_hrtimer_spinlock, flags);
+      /* cpus is a running reference counter and must never wrap */
 
-      /* Invoke the timer callback */
+      DEBUGASSERT(hrtimer->cpus != 0);
+
+      /* Leave critical section before invoking the callback */
+
+      write_sequnlock_irqrestore(&g_hrtimer_spinlock, flags);
+
+      /* Execute the timer callback */
 
       period = hrtimer->func(hrtimer);

Review Comment:
   Still violation of the ownership invariant.



-- 
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