From 0f1be60bda165bd8a8baf23a7c3634ad3c0aa0e1 Mon Sep 17 00:00:00 2001 From: Johan Fleury Date: Wed, 27 Feb 2019 21:18:20 -0500 Subject: [PATCH] fix(YubiKey): call `yk_release` on errors Fix #2643 and #2721 --- src/keys/drivers/YubiKey.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/keys/drivers/YubiKey.cpp b/src/keys/drivers/YubiKey.cpp index 884be354b..b4aa82205 100644 --- a/src/keys/drivers/YubiKey.cpp +++ b/src/keys/drivers/YubiKey.cpp @@ -77,6 +77,7 @@ bool YubiKey::init() // TODO: handle multiple attached hardware devices m_yk_void = static_cast(yk_open_first_key()); if (m_yk == nullptr) { + yk_release(); m_mutex.unlock(); return false; } @@ -85,6 +86,7 @@ bool YubiKey::init() if (m_ykds == nullptr) { yk_close_key(m_yk); m_yk_void = nullptr; + yk_release(); m_mutex.unlock(); return false; } @@ -107,6 +109,8 @@ bool YubiKey::deinit() m_ykds_void = nullptr; } + yk_release(); + m_mutex.unlock(); return true;