From: Martin Wilck <mwilck@xxxxxxxx> This fixes a coverity-reported defect (413387 Indefinite wait). Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> --- multipathd/init_unwinder.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/multipathd/init_unwinder.c b/multipathd/init_unwinder.c index 14467f3..b1cd283 100644 --- a/multipathd/init_unwinder.c +++ b/multipathd/init_unwinder.c @@ -4,10 +4,12 @@ static pthread_mutex_t dummy_mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t dummy_cond = PTHREAD_COND_INITIALIZER; +static int dummy_started; static void *dummy_thread(void *arg __attribute__((unused))) { pthread_mutex_lock(&dummy_mtx); + dummy_started = 1; pthread_cond_broadcast(&dummy_cond); pthread_mutex_unlock(&dummy_mtx); pause(); @@ -27,7 +29,9 @@ int init_unwinder(void) return rc; } - pthread_cond_wait(&dummy_cond, &dummy_mtx); + while (!dummy_started) + pthread_cond_wait(&dummy_cond, &dummy_mtx); + pthread_mutex_unlock(&dummy_mtx); return pthread_cancel(dummy); -- 2.43.0