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) { diff --git a/components/drivers/tty/n_tty.c b/components/drivers/tty/n_tty.c index 658c6c0d9e..ba27ae134b 100644 --- a/components/drivers/tty/n_tty.c +++ b/components/drivers/tty/n_tty.c @@ -536,7 +536,7 @@ static void __isig(int sig, struct tty_struct *tty) if (sig == SIGTSTP) { struct rt_lwp *old_lwp; - + rt_memcpy(&old_termios, &(tty->init_termios), sizeof(struct termios)); tty->init_termios = *new_termios; ld = tty->ldisc; @@ -549,7 +549,7 @@ static void __isig(int sig, struct tty_struct *tty) } tty_sigaddset(&lwp->signal_mask, SIGTTOU); old_lwp = tty_pop(&tty->head, RT_NULL); - tty->foreground = old_lwp; + tty->foreground = old_lwp; } else { @@ -805,7 +805,7 @@ static size_t __process_echoes(struct tty_struct *tty) unsigned char c = 0; char ch = 0; unsigned char num_chars = 0, num_bs = 0; - + tail = ldata->echo_tail; while (ldata->echo_commit != tail) { @@ -1126,7 +1126,19 @@ static int n_tty_open(struct dfs_fd *fd) } ldata->atomic_read_lock = rt_mutex_create("atomic_read_lock",RT_IPC_FLAG_FIFO); + if(ldata->atomic_read_lock == RT_NULL) + { + LOG_E("n_tty_open atomic_read_lock create fail"); + return -1; + } + ldata->output_lock = rt_mutex_create("output_lock",RT_IPC_FLAG_FIFO); + if(ldata->output_lock == RT_NULL) + { + LOG_E("n_tty_open output_lock create fail"); + return -1; + } + tty->disc_data = ldata; reset_buffer_flags(ldata); ldata->column = 0; diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index e7851c29cd..da9812d947 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -1016,6 +1016,8 @@ rt_err_t sys_sem_release(rt_sem_t sem) rt_mutex_t sys_mutex_create(const char *name, rt_uint8_t flag) { rt_mutex_t mutex = rt_mutex_create(name, flag); + if(mutex == NULL) + return NULL; if (lwp_user_object_add(lwp_self(), (rt_object_t)mutex) != 0) { rt_mutex_delete(mutex);