]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
gensec: Simplify gensec_security_by_fn()
authorVolker Lendecke <vl@samba.org>
Wed, 29 May 2024 15:11:51 +0000 (17:11 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 4 Jun 2024 07:11:35 +0000 (07:11 +0000)
We don't need that intermediate talloc ctx, we only allocate backends
and don't pass it anywhere else.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
auth/gensec/gensec_start.c

index 23e6e170ecd378091eaf8446303a022eb8065186..05d0d3cf7a780d8fa4176d17604c625e42148c6e 100644 (file)
@@ -192,16 +192,9 @@ static const struct gensec_security_ops *gensec_security_by_fn(
 {
        size_t i;
        const struct gensec_security_ops **backends = NULL;
-       TALLOC_CTX *mem_ctx = NULL;
 
-       mem_ctx = talloc_new(gensec_security);
-       if (!mem_ctx) {
-               return NULL;
-       }
-
-       backends = gensec_security_mechs(gensec_security, mem_ctx);
+       backends = gensec_security_mechs(gensec_security, gensec_security);
        if (backends == NULL) {
-               TALLOC_FREE(mem_ctx);
                return NULL;
        }
 
@@ -211,12 +204,12 @@ static const struct gensec_security_ops *gensec_security_by_fn(
 
                ok = fn(backend, private_data);
                if (ok) {
-                       TALLOC_FREE(mem_ctx);
+                       TALLOC_FREE(backends);
                        return backend;
                }
        }
 
-       TALLOC_FREE(mem_ctx);
+       TALLOC_FREE(backends);
        return NULL;
 }