Skip to content

Commit

Permalink
[fix bug] RT-Thread#3951
Browse files Browse the repository at this point in the history
  • Loading branch information
mysterywolf committed Oct 11, 2020
1 parent 13044b1 commit 2469335
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
* 2018-10-02 Bernard add 64bit support for mailbox
* 2019-09-16 tyx add send wait support for message queue
* 2020-07-29 Meco Man fix thread->event_set/event_info when received an
event without pending
* event without pending
* 2020-10-11 Meco Man add semaphore values' overflow-check code
* in the function of rt_sem_release
*/

#include <rtthread.h>
Expand Down Expand Up @@ -463,7 +465,17 @@ rt_err_t rt_sem_release(rt_sem_t sem)
need_schedule = RT_TRUE;
}
else
sem->value ++; /* increase value */
{
if(sem->value < 65535u)
{
sem->value ++; /* increase value */
}
else
{
rt_hw_interrupt_enable(temp); /* enable interrupt */
return -RT_EFULL; /* value overflowed */
}
}

/* enable interrupt */
rt_hw_interrupt_enable(temp);
Expand Down

0 comments on commit 2469335

Please sign in to comment.