From f1195229e016e2a3e1a7358ff87954d573b1dcac Mon Sep 17 00:00:00 2001
From: Alexey Tikhonov <atikhono@redhat.com>
Date: Fri, 13 May 2022 16:21:46 +0200
Subject: [PATCH] PAM P11: fixed minor mem-leak

Reviewed-by: Justin Stephenson <jstephen@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
---
 src/responder/pam/pamsrv_p11.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/responder/pam/pamsrv_p11.c b/src/responder/pam/pamsrv_p11.c
index ae1063365..bd205eb93 100644
--- a/src/responder/pam/pamsrv_p11.c
+++ b/src/responder/pam/pamsrv_p11.c
@@ -523,19 +523,22 @@ static errno_t parse_p11_child_response(TALLOC_CTX *mem_ctx, uint8_t *buf,
         cert_auth_info = talloc_zero(tmp_ctx, struct cert_auth_info);
         if (cert_auth_info == NULL) {
             DEBUG(SSSDBG_OP_FAILURE, "talloc_zero failed.\n");
-            return ENOMEM;
+            ret = ENOMEM;
+            goto done;
         }
 
         pn = memchr(p, '\n', buf_len - (p - buf));
         if (pn == NULL) {
             DEBUG(SSSDBG_OP_FAILURE,
                   "Missing new-line in p11_child response.\n");
-            return EINVAL;
+            ret = EINVAL;
+            goto done;
         }
         if (pn == p) {
             DEBUG(SSSDBG_OP_FAILURE,
                   "Missing counter in p11_child response.\n");
-            return EINVAL;
+            ret = EINVAL;
+            goto done;
         }
 
         cert_auth_info->token_name = talloc_strndup(cert_auth_info, (char *)p,
-- 
2.32.0.windows.1

