summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
authorSparks-Pion <[email protected]>2023-04-04 12:33:10 +0800
committerGitHub <[email protected]>2023-04-04 00:33:10 -0400
commitaccab17fa5eafc800c4ba464a0f6fcc1d1e008eb (patch)
tree82fae58ffc459407d673042edfa51a7abbe52078 /bsp
parent3bee170d5297ce9a142b20294a34822bd030d2c2 (diff)
[HUST CSE IoTS&P Lab] [fix] check rt_mutex_create return value (#7169)
Diffstat (limited to 'bsp')
-rw-r--r--bsp/allwinner/libraries/sunxi-hal/hal/source/sound/component/aw-alsa-utils/aduplex.c6
-rw-r--r--bsp/nuvoton/libraries/m031/rtt_port/drv_fmc.c1
-rw-r--r--bsp/nuvoton/libraries/m2354/rtt_port/drv_fmc.c1
-rw-r--r--bsp/nuvoton/libraries/nu_packages/Demo/smp_demo.c6
4 files changed, 14 insertions, 0 deletions
diff --git a/bsp/allwinner/libraries/sunxi-hal/hal/source/sound/component/aw-alsa-utils/aduplex.c b/bsp/allwinner/libraries/sunxi-hal/hal/source/sound/component/aw-alsa-utils/aduplex.c
index 6599526f98..5dc73d24cb 100644
--- a/bsp/allwinner/libraries/sunxi-hal/hal/source/sound/component/aw-alsa-utils/aduplex.c
+++ b/bsp/allwinner/libraries/sunxi-hal/hal/source/sound/component/aw-alsa-utils/aduplex.c
@@ -664,6 +664,11 @@ int cmd_aduplex(int argc, char ** argv)
}
duplex_priv.xMutex = rt_mutex_create("sound_mtx", RT_IPC_FLAG_PRIO);
+ if(duplex_priv.xMutex == RT_NULL) {
+ printf("mutex create failed.\n");
+ goto err_create_mutex;
+ }
+
// ret = xTaskCreate(arecord_entry, (signed portCHAR *) "arecord-thread",
// thread_size, &duplex_priv, priority, &pxCreatedTask);
// if (!ret) {
@@ -694,6 +699,7 @@ err_arecord_timeout:
// vTaskDelete(pxCreatedTask);
err_create_arecord:
err_format:
+err_create_mutex:
err_in_filename_null:
err_out_filename_null:
err_cmd:
diff --git a/bsp/nuvoton/libraries/m031/rtt_port/drv_fmc.c b/bsp/nuvoton/libraries/m031/rtt_port/drv_fmc.c
index b52c60571a..1b82d18729 100644
--- a/bsp/nuvoton/libraries/m031/rtt_port/drv_fmc.c
+++ b/bsp/nuvoton/libraries/m031/rtt_port/drv_fmc.c
@@ -318,6 +318,7 @@ static int nu_fmc_init(void)
SYS_LockReg();
g_mutex_fmc = rt_mutex_create("nu_fmc_lock", RT_IPC_FLAG_PRIO);
+ RT_ASSERT(g_mutex_fmc != RT_NULL);
/* RT_USING_FAL */
#if defined(RT_USING_FAL)
diff --git a/bsp/nuvoton/libraries/m2354/rtt_port/drv_fmc.c b/bsp/nuvoton/libraries/m2354/rtt_port/drv_fmc.c
index 04cb90f5c6..1f40b2efe7 100644
--- a/bsp/nuvoton/libraries/m2354/rtt_port/drv_fmc.c
+++ b/bsp/nuvoton/libraries/m2354/rtt_port/drv_fmc.c
@@ -315,6 +315,7 @@ static int nu_fmc_init(void)
SYS_LockReg();
g_mutex_fmc = rt_mutex_create("nu_fmc_lock", RT_IPC_FLAG_PRIO);
+ RT_ASSERT(g_mutex_fmc != RT_NULL);
/* RT_USING_FAL */
#if defined(RT_USING_FAL)
diff --git a/bsp/nuvoton/libraries/nu_packages/Demo/smp_demo.c b/bsp/nuvoton/libraries/nu_packages/Demo/smp_demo.c
index a3f8309521..31391faeb7 100644
--- a/bsp/nuvoton/libraries/nu_packages/Demo/smp_demo.c
+++ b/bsp/nuvoton/libraries/nu_packages/Demo/smp_demo.c
@@ -151,6 +151,12 @@ static int go_happy_mutex(void)
rt_thread_t thread;
rt_mutex_t sem = rt_mutex_create("mutexsem", RT_IPC_FLAG_PRIO);
+ if(sem == RT_NULL)
+ {
+ rt_kprintf("create mutex failed");
+ return (int)-RT_ERROR;
+ }
+
thread = rt_thread_create("mutex0", happy_mutex, (void *)sem, 2048, 25, 20);
if (thread != RT_NULL)
{