[HUST CSE IoTS&P Lab] [fix] check rt_mutex_create return value (#7169)

This commit is contained in:
Sparks-Pion 2023-04-04 12:33:10 +08:00 committed by GitHub
parent 3bee170d52
commit accab17fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 3 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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)

View File

@ -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)
{

View File

@ -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;

View File

@ -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);