anchao commented on code in PR #8321:
URL: https://github.com/apache/nuttx/pull/8321#discussion_r1089676303


##########
sched/semaphore/sem_post.c:
##########
@@ -89,7 +89,11 @@ int nxsem_post(FAR sem_t *sem)
 
   /* Check the maximum allowable value */
 
-  DEBUGASSERT(sem_count < SEM_VALUE_MAX);
+  if (sem_count >= SEM_VALUE_MAX)
+    {
+      leave_critical_section(flags);
+      return -EOVERFLOW;

Review Comment:
   This is a regression issue, the following commit remove the overflow check:
   
https://github.com/apache/nuttx/pull/7372/files#diff-d574e66ae803b2d22c93c05fa66a481b3d9a9bdd4459fd16d5223ba3cebcf549L95
   
   Some OS and libc implementations already have similar implementations.
   musl:
   https://github.com/bminor/musl/blob/master/src/thread/sem_post.c#L11
   There is a risk of sem_count overflowing if we do not limit it, at present, 
sabre-6quad/netnsh_wb is broken by #7372, I think we need fix the overflow 
issue first.
   
   



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