px4_shutdown_unlock: check that counter is > 0

This commit is contained in:
Beat Küng 2017-07-24 19:35:47 +02:00 committed by Lorenz Meier
parent 007b6dd8d7
commit c5a1d1928d
1 changed files with 7 additions and 1 deletions

View File

@ -66,7 +66,13 @@ int px4_shutdown_unlock()
int ret = pthread_mutex_lock(&shutdown_mutex);
if (ret == 0) {
--shutdown_lock_counter;
if (shutdown_lock_counter > 0) {
--shutdown_lock_counter;
} else {
PX4_ERR("unmatched number of px4_shutdown_unlock() calls");
}
return pthread_mutex_unlock(&shutdown_mutex);
}