From e04f415e669b91d8b944ed2a4751643b1472f1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=9A=E7=A5=96=E6=9C=9B?= <5171267+gongzuwang@user.noreply.gitee.com> Date: Fri, 17 Jul 2026 14:21:05 +0800 Subject: [PATCH 1/9] =?UTF-8?q?fix:=20=E5=B0=86=20RemoveObj=20=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=B1=BB=E5=9E=8B=E6=94=B9=E4=B8=BA=20void=EF=BC=8C?= =?UTF-8?q?=E6=B6=88=E9=99=A4=E6=9C=AA=E8=BF=94=E5=9B=9E=E5=80=BC=E9=9A=90?= =?UTF-8?q?=E6=82=A3=20(#21)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ubiquitous/XiZi_IIoT_Macro/kernel/thread/id.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/id.c b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/id.c index 1ad7dd59d..29fcdeff0 100644 --- a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/id.c +++ b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/id.c @@ -95,7 +95,7 @@ static struct IdNode *GetObj(struct IdManager *manager, uint16 id) return idnode; } -static struct IdNode *RemoveObj(struct IdManager *manager, struct IdNode *idnode) +static void RemoveObj(struct IdManager *manager, struct IdNode *idnode) { NULL_PARAM_CHECK(manager); NULL_PARAM_CHECK(idnode); -- 2.34.1 From 0f4bb95ad4f5e04c669831b5e799ec7ad0b82c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=9A=E7=A5=96=E6=9C=9B?= <5171267+gongzuwang@user.noreply.gitee.com> Date: Fri, 17 Jul 2026 14:30:08 +0800 Subject: [PATCH 2/9] =?UTF-8?q?fix:=20=E5=9C=A8=20SysInitOsAssign=20?= =?UTF-8?q?=E4=B8=AD=E8=B0=83=E7=94=A8=20=5F=5Finit=5Fssp=EF=BC=8C?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=20SSP=20canary=20(#20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ubiquitous/XiZi_IIoT_Macro/kernel/thread/assign.c | 5 +++++ Ubiquitous/XiZi_IIoT_Macro/kernel/thread/smp_assign.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/assign.c b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/assign.c index d2071eb1d..c024a290b 100644 --- a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/assign.c +++ b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/assign.c @@ -379,8 +379,13 @@ void StartupOsAssign(void) * * system OsAssign init function */ +extern void __init_ssp(void *); + void SysInitOsAssign(void) { + /* Initialize SSP canary before tasks run; NULL uses address-based fallback */ + __init_ssp(NONE); + SYS_KDEBUG_LOG(KDBG_SCHED, ("start Os Assign: max priority 0x%02x\n", KTASK_PRIORITY_MAX)); diff --git a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/smp_assign.c b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/smp_assign.c index d9f19419e..4ec7062a8 100644 --- a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/smp_assign.c +++ b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/smp_assign.c @@ -474,8 +474,13 @@ void StartupOsAssign(void) * * system OsAssign init function */ +extern void __init_ssp(void *); + void SysInitOsAssign(void) { + /* Initialize SSP canary before tasks run; NULL uses address-based fallback */ + __init_ssp(NONE); + SYS_KDEBUG_LOG(KDBG_SCHED, ("start Os Assign: max priority 0x%02x\n", KTASK_PRIORITY_MAX)); -- 2.34.1 From 022b34c2ba66ee904bfac6f18abe2a286249a737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=9A=E7=A5=96=E6=9C=9B?= <5171267+gongzuwang@user.noreply.gitee.com> Date: Fri, 17 Jul 2026 14:36:31 +0800 Subject: [PATCH 3/9] =?UTF-8?q?fix:=20=E5=AF=B9=E9=BD=90=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=98=9F=E5=88=97=20send/recv=20=E7=9A=84=20exstatus=20?= =?UTF-8?q?=E4=B8=8E=E8=BF=94=E5=9B=9E=E5=80=BC=20(#18)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c index e4f9a63dd..a47b4030b 100644 --- a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c +++ b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c @@ -109,6 +109,7 @@ static x_err_t _MsgQueueSend(struct MsgQueue* mq, lock = CriticalAreaLock(); if (mq->num_msgs >= mq->max_msgs && timeout == 0) { CriticalAreaUnLock(lock); + task->exstatus = -EFULL; return -EFULL; } @@ -116,6 +117,7 @@ static x_err_t _MsgQueueSend(struct MsgQueue* mq, task->exstatus = EOK; if (timeout == 0) { CriticalAreaUnLock(lock); + task->exstatus = -EFULL; return -EFULL; } KDEBUG_IN_KTASK_CONTEXT; @@ -216,6 +218,7 @@ static x_err_t _MsgQueueRecv(struct MsgQueue* mq, lock = CriticalAreaLock(); if (timeout == 0 && mq->num_msgs <= 0) { CriticalAreaUnLock(lock); + task->exstatus = -ETIMEOUT; return -ETIMEOUT; } -- 2.34.1 From ce40feef0efc0f8b0af4dae6e4e9fe1ced8c53a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=9A=E7=A5=96=E6=9C=9B?= <5171267+gongzuwang@user.noreply.gitee.com> Date: Fri, 17 Jul 2026 14:39:24 +0800 Subject: [PATCH 4/9] =?UTF-8?q?refactor:=20=E5=88=A0=E9=99=A4=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E9=98=9F=E5=88=97=20send/recv=20=E4=B8=AD=20timeout?= =?UTF-8?q?=3D=3D0=20=E7=9A=84=E5=86=97=E4=BD=99=E5=88=A4=E6=96=AD=20(#17)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c index a47b4030b..c654d8db9 100644 --- a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c +++ b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c @@ -107,12 +107,6 @@ static x_err_t _MsgQueueSend(struct MsgQueue* mq, timeout = CalculateTickFromTimeMs(msec); lock = CriticalAreaLock(); - if (mq->num_msgs >= mq->max_msgs && timeout == 0) { - CriticalAreaUnLock(lock); - task->exstatus = -EFULL; - return -EFULL; - } - while (mq->num_msgs >= mq->max_msgs) { task->exstatus = EOK; if (timeout == 0) { @@ -216,12 +210,6 @@ static x_err_t _MsgQueueRecv(struct MsgQueue* mq, timeout = CalculateTickFromTimeMs(msec); lock = CriticalAreaLock(); - if (timeout == 0 && mq->num_msgs <= 0) { - CriticalAreaUnLock(lock); - task->exstatus = -ETIMEOUT; - return -ETIMEOUT; - } - while (mq->num_msgs <= 0) { KDEBUG_IN_KTASK_CONTEXT; -- 2.34.1 From 9e2efde7d9f91ea90ccb52da399fe0f455e3b96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=9A=E7=A5=96=E6=9C=9B?= <5171267+gongzuwang@user.noreply.gitee.com> Date: Fri, 17 Jul 2026 14:42:56 +0800 Subject: [PATCH 5/9] =?UTF-8?q?fix:=20=E9=98=B2=E6=AD=A2=20=5FSemaphoreAba?= =?UTF-8?q?ndon=20=E4=B8=AD=20sem->value=20=E6=BA=A2=E5=87=BA=20(#16)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ubiquitous/XiZi_IIoT_Macro/kernel/thread/semaphore.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/semaphore.c b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/semaphore.c index 8a461aa88..11aec38a7 100644 --- a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/semaphore.c +++ b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/semaphore.c @@ -177,6 +177,10 @@ static int32 _SemaphoreAbandon(int32 id) resched = 1; LinklistResume(&sem->pend_list); } else { + if (sem->value == UINT16_MAX) { + CriticalAreaUnLock(lock); + return -EFULL; + } sem->value++; } -- 2.34.1 From 5dcb8db2f70e01ecd1043db7d670ecda659bb12e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=9A=E7=A5=96=E6=9C=9B?= <5171267+gongzuwang@user.noreply.gitee.com> Date: Fri, 17 Jul 2026 14:52:32 +0800 Subject: [PATCH 6/9] =?UTF-8?q?fix:=20CircularAreaInit=20=E5=9C=A8=20data?= =?UTF-8?q?=5Fbuffer=20=E5=88=86=E9=85=8D=E5=A4=B1=E8=B4=A5=E6=97=B6?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E9=87=8A=E6=94=BE=20descriptor=20(#10)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ubiquitous/XiZi_IIoT_Macro/kernel/thread/circular_area.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/circular_area.c b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/circular_area.c index 92809e54b..0ae4563e4 100644 --- a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/circular_area.c +++ b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/circular_area.c @@ -253,7 +253,6 @@ CircularAreaType CircularAreaInit(uint32 circular_area_length) CircularAreaType circular_area = x_malloc(sizeof(struct CircularArea)); if(NONE == circular_area) { KPrintf("CircularAreaInit malloc struct circular_area failed\n"); - x_free(circular_area); return NONE; } @@ -262,7 +261,7 @@ CircularAreaType CircularAreaInit(uint32 circular_area_length) circular_area->data_buffer = x_malloc(circular_area_length); if(NONE == circular_area->data_buffer) { KPrintf("CircularAreaInit malloc circular_area data_buffer failed\n"); - x_free(circular_area->data_buffer); + x_free(circular_area); return NONE; } -- 2.34.1 From ee2004f5aa67de794f21fc65015edc52133d912e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=9A=E7=A5=96=E6=9C=9B?= <5171267+gongzuwang@user.noreply.gitee.com> Date: Fri, 17 Jul 2026 14:54:56 +0800 Subject: [PATCH 7/9] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=20AvlTreeBalance?= =?UTF-8?q?=20=E5=88=A0=E9=99=A4=E5=90=8E=E5=AD=90=E6=A0=91=20BF=20?= =?UTF-8?q?=E4=B8=BA=200=20=E7=9A=84=E6=97=8B=E8=BD=AC=E5=A4=84=E7=90=86?= =?UTF-8?q?=20(#9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XiZi_IIoT_Macro/kernel/thread/avl_tree.c | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/avl_tree.c b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/avl_tree.c index 76d340e68..a9dad6c38 100644 --- a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/avl_tree.c +++ b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/avl_tree.c @@ -157,35 +157,33 @@ static AvlNodeType AvlTreeSetRLRotate(AvlNodeType avl_node) */ static AvlNodeType AvlTreeBalance(AvlNodeType avl_node) { - if(avl_node) - { - AvlNodeType new_node = NONE; - uint32 avlnode_BF = AVL_ABS(AvlTreeGetNodeBalanceFactor(avl_node)); + int32 bf = 0; + int32 child_bf = 0; - if(avlnode_BF > 1) { - if(AvlTreeGetNodeBalanceFactor(avl_node->left) > 0) { - /*LL case*/ - new_node = AvlTreeSetRightRotate(avl_node); - } else if(AvlTreeGetNodeBalanceFactor(avl_node->left) < 0) { - /*LR case*/ - new_node = AvlTreeSetLRRotate(avl_node); - } else if(AvlTreeGetNodeBalanceFactor(avl_node->right) < 0) { - /*RR case*/ - new_node = AvlTreeSetLeftRotate(avl_node); - } else if(AvlTreeGetNodeBalanceFactor(avl_node->right) > 0) { - /*RL case*/ - new_node = AvlTreeSetRLRotate(avl_node); - } - } else { - /*the avl tree is balanced, no need to rebalance*/ - new_node = avl_node; - } - - return new_node; - - } else { + if (avl_node == NONE) return NONE; + + bf = AvlTreeGetNodeBalanceFactor(avl_node); + + if (bf > 1) { + /* Left-heavy: LL (incl. left BF == 0 after delete) or LR */ + child_bf = AvlTreeGetNodeBalanceFactor(avl_node->left); + if (child_bf >= 0) + return AvlTreeSetRightRotate(avl_node); + else + return AvlTreeSetLRRotate(avl_node); } + + if (bf < -1) { + /* Right-heavy: RR (incl. right BF == 0 after delete) or RL */ + child_bf = AvlTreeGetNodeBalanceFactor(avl_node->right); + if (child_bf <= 0) + return AvlTreeSetLeftRotate(avl_node); + else + return AvlTreeSetRLRotate(avl_node); + } + + return avl_node; } /** -- 2.34.1 From 2fd6d03326d42fde8223978b953339d82a82abea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=9A=E7=A5=96=E6=9C=9B?= <5171267+gongzuwang@user.noreply.gitee.com> Date: Fri, 17 Jul 2026 14:56:14 +0800 Subject: [PATCH 8/9] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=20AvlTreeInsertNo?= =?UTF-8?q?de=20malloc=20=E5=A4=B1=E8=B4=A5=E6=97=B6=E5=AF=B9=20NULL=20?= =?UTF-8?q?=E7=9A=84=E6=97=A0=E6=95=88=20x=5Ffree=20(#8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ubiquitous/XiZi_IIoT_Macro/kernel/thread/avl_tree.c | 1 - 1 file changed, 1 deletion(-) diff --git a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/avl_tree.c b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/avl_tree.c index a9dad6c38..f39e79ed1 100644 --- a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/avl_tree.c +++ b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/avl_tree.c @@ -200,7 +200,6 @@ AvlNodeType AvlTreeInsertNode(AvlNodeType avl_node, int32 data) new_node = x_malloc(sizeof(struct AvlNode)); if(NONE == new_node) { KPrintf("AvlTreeInsertNode malloc AvlNode failed\n"); - x_free(new_node); return NONE; } new_node->data = data; -- 2.34.1 From 8dfe689f3a8d4438a81fd2c349b808caa0afff5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=9A=E7=A5=96=E6=9C=9B?= <5171267+gongzuwang@user.noreply.gitee.com> Date: Fri, 17 Jul 2026 16:40:51 +0800 Subject: [PATCH 9/9] =?UTF-8?q?fix:=20ExtSramInitBoardMemory=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20extsram=5Fidx=20=E4=B8=8A=E7=95=8C=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ubiquitous/XiZi_IIoT_Macro/kernel/memory/byte_manage.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Ubiquitous/XiZi_IIoT_Macro/kernel/memory/byte_manage.c b/Ubiquitous/XiZi_IIoT_Macro/kernel/memory/byte_manage.c index 80ce5e7cd..9e5ea78c1 100644 --- a/Ubiquitous/XiZi_IIoT_Macro/kernel/memory/byte_manage.c +++ b/Ubiquitous/XiZi_IIoT_Macro/kernel/memory/byte_manage.c @@ -881,6 +881,11 @@ void ExtSramInitBoardMemory(void* start_phy_address, void* end_phy_address, uint NULL_PARAM_CHECK(start_phy_address); NULL_PARAM_CHECK(end_phy_address); + if (extsram_idx >= EXTSRAM_MAX_NUM) { + KPrintf("ExtSramInitBoardMemory, invalid extsram_idx %u\n", extsram_idx); + return; + } + KDEBUG_NOT_IN_INTERRUPT; struct DynamicBuddyMemory* uheap = &ExtByteManager[extsram_idx].dynamic_buddy_manager; -- 2.34.1