Skip to content

Commit

Permalink
fix: add mutex free value guard (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland authored Jul 19, 2024
1 parent ac364c0 commit e837b67
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/system/zephyr/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ void z_task_free(z_task_t **task) {
/*------------------ Mutex ------------------*/
int8_t z_mutex_init(z_mutex_t *m) { return pthread_mutex_init(m, 0); }

int8_t z_mutex_free(z_mutex_t *m) { return pthread_mutex_destroy(m); }
int8_t z_mutex_free(z_mutex_t *m) {
if (*m == NULL) {
return 0;
}
return pthread_mutex_destroy(m);
}

int8_t z_mutex_lock(z_mutex_t *m) { return pthread_mutex_lock(m); }

Expand Down

1 comment on commit e837b67

@ypearson-bdai
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean if(m == NULL)?

Please sign in to comment.