Skip to content

Commit fd441f8

Browse files
olszomalmtrojnar
authored andcommitted
Add missing lock for rw_mode in pkcs11_init_keygen(), CID 459656
1 parent 5e46f08 commit fd441f8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/p11_key.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,14 +815,17 @@ static int pkcs11_init_key(PKCS11_SLOT_private *slot, CK_SESSION_HANDLE session,
815815

816816
static int pkcs11_init_keygen(PKCS11_SLOT_private *slot, CK_SESSION_HANDLE *session)
817817
{
818+
pthread_mutex_lock(&slot->lock);
818819
/* R/W session is mandatory for key generation. */
819820
if (slot->rw_mode != 1) {
821+
pthread_mutex_unlock(&slot->lock);
820822
if (pkcs11_open_session(slot, 1))
821823
return -1;
822824
/* open_session will call C_CloseAllSessions which logs everyone out */
823825
if (pkcs11_login(slot, 0, slot->prev_pin))
824826
return -1;
825827
}
828+
pthread_mutex_unlock(&slot->lock);
826829
return pkcs11_get_session(slot, 1, session);
827830
}
828831

0 commit comments

Comments
 (0)