Skip to content

Commit

Permalink
feat: add malloc value guards for freertos (#527)
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Jul 11, 2024
1 parent 07ae1b7 commit ac364c0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/system/freertos_plus_tcp/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,20 @@ void z_task_free(z_task_t **task) {

/*------------------ Mutex ------------------*/
int8_t z_mutex_init(z_mutex_t *m) {
if (m == NULL) {
return -1;
}
*m = xSemaphoreCreateRecursiveMutex();
return *m == NULL ? -1 : 0;
}

int8_t z_mutex_free(z_mutex_t *m) {
if (m == NULL) {
return -1;
}
if (*m == NULL) {
return 0;
}
z_free(*m);
return 0;
}
Expand Down

0 comments on commit ac364c0

Please sign in to comment.