From b93b4942390dbcf0834f762145c7784d6b32075c Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Wed, 21 Oct 2020 17:15:43 +0800 Subject: [PATCH] [bug fixed] add mutex values' overflow-check code --- src/ipc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ipc.c b/src/ipc.c index dc347119ae..129d3eea44 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -37,7 +37,7 @@ * 2020-07-29 Meco Man fix thread->event_set/event_info when received an * event without pending * 2020-10-11 Meco Man add semaphore values' overflow-check code - * in the function of rt_sem_release + * 2020-10-21 Meco Man add mutex values' overflow-check code */ #include @@ -697,8 +697,16 @@ rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time) if (mutex->owner == thread) { - /* it's the same thread */ - mutex->hold ++; + if(mutex->hold < 255u) + { + /* it's the same thread */ + mutex->hold ++; + } + else + { + rt_hw_interrupt_enable(temp); /* enable interrupt */ + return -RT_EFULL; /* value overflowed */ + } } else {