From c79b00e323efc84c2df057a963d7165a6050b8fb Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Mon, 1 Dec 2025 17:11:57 +0800 Subject: [PATCH 1/2] [DM/PIC] Fixup SMP CPU mask list when CPU < 4 Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/pic/pic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/drivers/pic/pic.c b/components/drivers/pic/pic.c index 66834944287..4194692fd1d 100644 --- a/components/drivers/pic/pic.c +++ b/components/drivers/pic/pic.c @@ -1198,7 +1198,7 @@ static int list_irq(int argc, char**argv) _pic_name_max, "PIC", 12, "Mode", #ifdef RT_USING_SMP - RT_CPUS_NR, "CPUs", + rt_max(RT_CPUS_NR, 4), "CPUs", #else 0, 0, #endif @@ -1254,6 +1254,10 @@ static int list_irq(int argc, char**argv) rt_kputs(info); #ifdef RT_USING_SMP + if (RT_CPUS_NR < 4) + { + rt_memset(&cpumask[RT_CPUS_NR], ' ', 4 - RT_CPUS_NR); + } rt_kputs(cpumask); #endif From 34da8f9c6ea99445434dd5a1299cf6e91c903307 Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Mon, 8 Dec 2025 11:22:05 +0800 Subject: [PATCH 2/2] [DM][PIC] Fix #10998 The size of cpumask is `RT_CPUS_NR`, memset force to space will overflow in stack. Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/pic/pic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/drivers/pic/pic.c b/components/drivers/pic/pic.c index 4194692fd1d..eca49ae24d2 100644 --- a/components/drivers/pic/pic.c +++ b/components/drivers/pic/pic.c @@ -1254,11 +1254,11 @@ static int list_irq(int argc, char**argv) rt_kputs(info); #ifdef RT_USING_SMP + rt_kputs(cpumask); if (RT_CPUS_NR < 4) { - rt_memset(&cpumask[RT_CPUS_NR], ' ', 4 - RT_CPUS_NR); + rt_kprintf("%-*.s", 4 - RT_CPUS_NR, " "); } - rt_kputs(cpumask); #endif #ifdef RT_USING_INTERRUPT_INFO