From cac5caec8b5d879837bda9404be246ba6f429c88 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Wed, 30 Sep 2015 16:18:18 -0700 Subject: [PATCH] nvme: sync up unit test nvme_impl.h mutex wrapper The default version of nvme_impl.h was cleaned up to release the pthread mutex attr on failure cases, but the unit test version did not receive this update. Change-Id: I899b7dc809393dc8e6fd24ed98e1d0a61ecf1c95 Signed-off-by: Daniel Verkamp --- test/lib/nvme/unit/nvme_impl.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/lib/nvme/unit/nvme_impl.h b/test/lib/nvme/unit/nvme_impl.h index ca6083fb8..248f2fbfc 100644 --- a/test/lib/nvme/unit/nvme_impl.h +++ b/test/lib/nvme/unit/nvme_impl.h @@ -101,14 +101,17 @@ static inline int nvme_mutex_init_recursive(nvme_mutex_t *mtx) { pthread_mutexattr_t attr; + int rc = 0; if (pthread_mutexattr_init(&attr)) { return -1; } - if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) { - return -1; + if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) || + pthread_mutex_init(mtx, &attr)) { + rc = -1; } - return pthread_mutex_init(mtx, &attr); + pthread_mutexattr_destroy(&attr); + return rc; } /**