From 4cade2815d2c42ce8b26f182ba35a1a478f0f656 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 30 Nov 2023 16:43:56 -0500 Subject: [PATCH] Fix incorrect error handling Originally discovered by Coverity as an unused value and a NULL dereference, it was actually an unfinished error condition check. Fixes CID 469486: Code maintainability issues (UNUSED_VALUE) Fixes CID 469485: Null pointer dereferences (FORWARD_NULL) Signed-off-by: Simo Sorce --- src/session.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/session.c b/src/session.c index 50f90cd1..b345f808 100644 --- a/src/session.c +++ b/src/session.c @@ -559,11 +559,13 @@ CK_RV p11prov_context_specific_login(P11PROV_SESSION *session, P11PROV_URI *uri, slot = p11prov_get_slot_by_id(sctx, p11prov_session_slotid(session)); if (!slot) { ret = CKR_GENERAL_ERROR; + goto done; } ret = token_login(session, uri, pw_cb, pw_cbarg, slot, CKU_CONTEXT_SPECIFIC); +done: p11prov_return_slots(sctx); return ret; }