[PATCH] Remove last easy talloc_autofree_context() usage.

Jeremy Allison jra at samba.org
Fri May 12 21:37:41 UTC 2017


Plumbs in the talloc contexts through the init
functions into the register functions. Removes
the last few "easy" uses of talloc_autofree_context()
in the s4 client tools.

Future patches to do this will get a little harder
as I have to look carefully at what the talloc_autofree_context()
is actually doing and why it might be there :-).

Passes full local make test.

Please review and push if happy !

Cheers,

	Jeremy.
-------------- next part --------------
From d6024a5c439a59ee1d6a254da43d0d0607920755 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Thu, 11 May 2017 15:45:57 -0700
Subject: [PATCH 1/7] s4: ntvfs: Add a TALLOC_CTX * paramter to
 pvfs_acl_register()

Make use of the passed in TALLOC_CTX * from the init function
to remove a talloc_autofree_context() use.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/ntvfs/posix/pvfs_acl.c       | 5 +++--
 source4/ntvfs/posix/pvfs_acl_nfs4.c  | 2 +-
 source4/ntvfs/posix/pvfs_acl_xattr.c | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/source4/ntvfs/posix/pvfs_acl.c b/source4/ntvfs/posix/pvfs_acl.c
index 9a110ca..d284585 100644
--- a/source4/ntvfs/posix/pvfs_acl.c
+++ b/source4/ntvfs/posix/pvfs_acl.c
@@ -41,7 +41,7 @@ static int num_backends;
   The 'name' can be later used by other backends to find the operations
   structure for this backend.  
 */
-NTSTATUS pvfs_acl_register(const struct pvfs_acl_ops *ops)
+NTSTATUS pvfs_acl_register(TALLOC_CTX *ctx, const struct pvfs_acl_ops *ops)
 {
 	struct pvfs_acl_ops *new_ops;
 
@@ -50,7 +50,8 @@ NTSTATUS pvfs_acl_register(const struct pvfs_acl_ops *ops)
 		return NT_STATUS_OBJECT_NAME_COLLISION;
 	}
 
-	backends = talloc_realloc(talloc_autofree_context(), backends, struct pvfs_acl_backend, num_backends+1);
+	backends = talloc_realloc(ctx, backends,
+			struct pvfs_acl_backend, num_backends+1);
 	NT_STATUS_HAVE_NO_MEMORY(backends);
 
 	new_ops = (struct pvfs_acl_ops *)talloc_memdup(backends, ops, sizeof(*ops));
diff --git a/source4/ntvfs/posix/pvfs_acl_nfs4.c b/source4/ntvfs/posix/pvfs_acl_nfs4.c
index 392dc92..b07d2ba 100644
--- a/source4/ntvfs/posix/pvfs_acl_nfs4.c
+++ b/source4/ntvfs/posix/pvfs_acl_nfs4.c
@@ -195,5 +195,5 @@ NTSTATUS pvfs_acl_nfs4_init(TALLOC_CTX *ctx)
 		.acl_load = pvfs_acl_load_nfs4,
 		.acl_save = pvfs_acl_save_nfs4
 	};
-	return pvfs_acl_register(&ops);
+	return pvfs_acl_register(ctx, &ops);
 }
diff --git a/source4/ntvfs/posix/pvfs_acl_xattr.c b/source4/ntvfs/posix/pvfs_acl_xattr.c
index 648c459..1f569ca 100644
--- a/source4/ntvfs/posix/pvfs_acl_xattr.c
+++ b/source4/ntvfs/posix/pvfs_acl_xattr.c
@@ -100,5 +100,5 @@ NTSTATUS pvfs_acl_xattr_init(TALLOC_CTX *ctx)
 		.acl_load = pvfs_acl_load_xattr,
 		.acl_save = pvfs_acl_save_xattr
 	};
-	return pvfs_acl_register(&ops);
+	return pvfs_acl_register(ctx, &ops);
 }
-- 
2.7.4


From d1ebb3fbbac2e98be631fe2132bdd313e0b4d7a4 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Thu, 11 May 2017 15:49:28 -0700
Subject: [PATCH 2/7] s4: ntvfs: Add a TALLOC_CTX * to sys_lease_register().

Pass in the TALLOC_CTX * from the module init to remove
another talloc_autofree_context() use.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/ntvfs/sysdep/sys_lease.c       | 5 +++--
 source4/ntvfs/sysdep/sys_lease.h       | 2 +-
 source4/ntvfs/sysdep/sys_lease_linux.c | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/source4/ntvfs/sysdep/sys_lease.c b/source4/ntvfs/sysdep/sys_lease.c
index 3db6703..b6e6ffc 100644
--- a/source4/ntvfs/sysdep/sys_lease.c
+++ b/source4/ntvfs/sysdep/sys_lease.c
@@ -103,10 +103,11 @@ _PUBLIC_ struct sys_lease_context *sys_lease_context_create(struct share_config
 /*
   register a lease backend
 */
-_PUBLIC_ NTSTATUS sys_lease_register(const struct sys_lease_ops *backend)
+_PUBLIC_ NTSTATUS sys_lease_register(TALLOC_CTX *ctx,
+			const struct sys_lease_ops *backend)
 {
 	struct sys_lease_ops *b;
-	b = talloc_realloc(talloc_autofree_context(), backends,
+	b = talloc_realloc(ctx, backends,
 			   struct sys_lease_ops, num_backends+1);
 	NT_STATUS_HAVE_NO_MEMORY(b);
 	backends = b;
diff --git a/source4/ntvfs/sysdep/sys_lease.h b/source4/ntvfs/sysdep/sys_lease.h
index 57a5e0a..8b8d4bd 100644
--- a/source4/ntvfs/sysdep/sys_lease.h
+++ b/source4/ntvfs/sysdep/sys_lease.h
@@ -47,7 +47,7 @@ struct sys_lease_context {
 	const struct sys_lease_ops *ops;
 };
 
-NTSTATUS sys_lease_register(const struct sys_lease_ops *ops);
+NTSTATUS sys_lease_register(TALLOC_CTX *ctx, const struct sys_lease_ops *ops);
 NTSTATUS sys_lease_init(void);
 
 struct sys_lease_context *sys_lease_context_create(struct share_config *scfg,
diff --git a/source4/ntvfs/sysdep/sys_lease_linux.c b/source4/ntvfs/sysdep/sys_lease_linux.c
index 1c70f4e..566a9a3 100644
--- a/source4/ntvfs/sysdep/sys_lease_linux.c
+++ b/source4/ntvfs/sysdep/sys_lease_linux.c
@@ -211,5 +211,5 @@ static struct sys_lease_ops linux_lease_ops = {
 NTSTATUS sys_lease_linux_init(TALLOC_CTX *ctx)
 {
 	/* register ourselves as a system lease module */
-	return sys_lease_register(&linux_lease_ops);
+	return sys_lease_register(ctx, &linux_lease_ops);
 }
-- 
2.7.4


From efd67608d5ebb19b3c31b45e98183f958e32ce35 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Thu, 11 May 2017 15:50:08 -0700
Subject: [PATCH 3/7] s4: ntvfs: Add a TALLOC_CTX * to sys_notify_register().

Pass in the TALLOC_CTX * from the module init to remove
another talloc_autofree_context() use.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/ntvfs/sysdep/inotify.c    | 2 +-
 source4/ntvfs/sysdep/sys_notify.c | 5 +++--
 source4/ntvfs/sysdep/sys_notify.h | 3 ++-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/source4/ntvfs/sysdep/inotify.c b/source4/ntvfs/sysdep/inotify.c
index c769618..ba4b336 100644
--- a/source4/ntvfs/sysdep/inotify.c
+++ b/source4/ntvfs/sysdep/inotify.c
@@ -394,5 +394,5 @@ NTSTATUS sys_notify_inotify_init(TALLOC_CTX *);
 NTSTATUS sys_notify_inotify_init(TALLOC_CTX *ctx)
 {
 	/* register ourselves as a system inotify module */
-	return sys_notify_register(&inotify);
+	return sys_notify_register(ctx, &inotify);
 }
diff --git a/source4/ntvfs/sysdep/sys_notify.c b/source4/ntvfs/sysdep/sys_notify.c
index aad3b90..7e00032 100644
--- a/source4/ntvfs/sysdep/sys_notify.c
+++ b/source4/ntvfs/sysdep/sys_notify.c
@@ -120,10 +120,11 @@ _PUBLIC_ NTSTATUS sys_notify_watch(struct sys_notify_context *ctx,
 /*
   register a notify backend
 */
-_PUBLIC_ NTSTATUS sys_notify_register(struct sys_notify_backend *backend)
+_PUBLIC_ NTSTATUS sys_notify_register(TALLOC_CTX *ctx,
+			struct sys_notify_backend *backend)
 {
 	struct sys_notify_backend *b;
-	b = talloc_realloc(talloc_autofree_context(), backends, 
+	b = talloc_realloc(ctx, backends,
 			   struct sys_notify_backend, num_backends+1);
 	NT_STATUS_HAVE_NO_MEMORY(b);
 	backends = b;
diff --git a/source4/ntvfs/sysdep/sys_notify.h b/source4/ntvfs/sysdep/sys_notify.h
index d912a9b..9e10f14 100644
--- a/source4/ntvfs/sysdep/sys_notify.h
+++ b/source4/ntvfs/sysdep/sys_notify.h
@@ -43,7 +43,8 @@ struct sys_notify_backend {
 	notify_watch_t notify_watch;
 };
 
-NTSTATUS sys_notify_register(struct sys_notify_backend *backend);
+NTSTATUS sys_notify_register(TALLOC_CTX *ctx,
+			struct sys_notify_backend *backend);
 struct sys_notify_context *sys_notify_context_create(struct share_config *scfg,
 						     TALLOC_CTX *mem_ctx, 
 						     struct tevent_context *ev);
-- 
2.7.4


From a949d1025103ca50dd8dda5faac1211cb9df0a01 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Thu, 11 May 2017 15:56:29 -0700
Subject: [PATCH 4/7] gensec: Add a TALLOC_CTX * to gensec_register().

Pass in the TALLOC_CTX * from the module init to remove
another talloc_autofree_context() use.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 auth/gensec/external.c              | 2 +-
 auth/gensec/gensec.h                | 3 ++-
 auth/gensec/gensec_start.c          | 5 +++--
 auth/gensec/ncalrpc.c               | 2 +-
 auth/gensec/schannel.c              | 2 +-
 auth/gensec/spnego.c                | 2 +-
 auth/ntlmssp/ntlmssp.c              | 4 ++--
 source4/auth/gensec/gensec_gssapi.c | 6 +++---
 source4/auth/gensec/gensec_krb5.c   | 4 ++--
 source4/lib/http/gensec/basic.c     | 2 +-
 source4/lib/http/gensec/ntlm.c      | 2 +-
 11 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/auth/gensec/external.c b/auth/gensec/external.c
index 92295bc..0158045 100644
--- a/auth/gensec/external.c
+++ b/auth/gensec/external.c
@@ -115,7 +115,7 @@ NTSTATUS gensec_external_init(TALLOC_CTX *ctx)
 {
 	NTSTATUS ret;
 
-	ret = gensec_register(&gensec_external_ops);
+	ret = gensec_register(ctx, &gensec_external_ops);
 	if (!NT_STATUS_IS_OK(ret)) {
 		DEBUG(0,("Failed to register '%s' gensec backend!\n",
 			 gensec_external_ops.name));
diff --git a/auth/gensec/gensec.h b/auth/gensec/gensec.h
index 3924a7c..e7b9477 100644
--- a/auth/gensec/gensec.h
+++ b/auth/gensec/gensec.h
@@ -181,7 +181,8 @@ NTSTATUS gensec_start_mech_by_oid(struct gensec_security *gensec_security,
 const char *gensec_get_name_by_oid(struct gensec_security *gensec_security, const char *oid_string);
 struct cli_credentials *gensec_get_credentials(struct gensec_security *gensec_security);
 NTSTATUS gensec_init(void);
-NTSTATUS gensec_register(const struct gensec_security_ops *ops);
+NTSTATUS gensec_register(TALLOC_CTX *ctx,
+		const struct gensec_security_ops *ops);
 const struct gensec_security_ops *gensec_security_by_oid(struct gensec_security *gensec_security,
 							 const char *oid_string);
 const struct gensec_security_ops *gensec_security_by_sasl_name(struct gensec_security *gensec_security,
diff --git a/auth/gensec/gensec_start.c b/auth/gensec/gensec_start.c
index 83a86cf..0f7e826 100644
--- a/auth/gensec/gensec_start.c
+++ b/auth/gensec/gensec_start.c
@@ -893,7 +893,8 @@ _PUBLIC_ NTSTATUS gensec_set_credentials(struct gensec_security *gensec_security
   The 'name' can be later used by other backends to find the operations
   structure for this backend.
 */
-_PUBLIC_ NTSTATUS gensec_register(const struct gensec_security_ops *ops)
+_PUBLIC_ NTSTATUS gensec_register(TALLOC_CTX *ctx,
+			const struct gensec_security_ops *ops)
 {
 	if (gensec_security_by_name(NULL, ops->name) != NULL) {
 		/* its already registered! */
@@ -902,7 +903,7 @@ _PUBLIC_ NTSTATUS gensec_register(const struct gensec_security_ops *ops)
 		return NT_STATUS_OBJECT_NAME_COLLISION;
 	}
 
-	generic_security_ops = talloc_realloc(talloc_autofree_context(),
+	generic_security_ops = talloc_realloc(ctx,
 					      generic_security_ops,
 					      const struct gensec_security_ops *,
 					      gensec_num_backends+2);
diff --git a/auth/gensec/ncalrpc.c b/auth/gensec/ncalrpc.c
index 8916ef5..f28a1c4 100644
--- a/auth/gensec/ncalrpc.c
+++ b/auth/gensec/ncalrpc.c
@@ -342,7 +342,7 @@ _PUBLIC_ NTSTATUS gensec_ncalrpc_as_system_init(TALLOC_CTX *ctx)
 {
 	NTSTATUS status;
 
-	status = gensec_register(&gensec_ncalrpc_security_ops);
+	status = gensec_register(ctx, &gensec_ncalrpc_security_ops);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0, ("Failed to register '%s' gensec backend!\n",
 			  gensec_ncalrpc_security_ops.name));
diff --git a/auth/gensec/schannel.c b/auth/gensec/schannel.c
index bf169d4..41f6351 100644
--- a/auth/gensec/schannel.c
+++ b/auth/gensec/schannel.c
@@ -852,7 +852,7 @@ static const struct gensec_security_ops gensec_schannel_security_ops = {
 _PUBLIC_ NTSTATUS gensec_schannel_init(TALLOC_CTX *ctx)
 {
 	NTSTATUS ret;
-	ret = gensec_register(&gensec_schannel_security_ops);
+	ret = gensec_register(ctx, &gensec_schannel_security_ops);
 	if (!NT_STATUS_IS_OK(ret)) {
 		DEBUG(0,("Failed to register '%s' gensec backend!\n",
 			gensec_schannel_security_ops.name));
diff --git a/auth/gensec/spnego.c b/auth/gensec/spnego.c
index 4b3edc6..484f491 100644
--- a/auth/gensec/spnego.c
+++ b/auth/gensec/spnego.c
@@ -1697,7 +1697,7 @@ static const struct gensec_security_ops gensec_spnego_security_ops = {
 _PUBLIC_ NTSTATUS gensec_spnego_init(TALLOC_CTX *ctx)
 {
 	NTSTATUS ret;
-	ret = gensec_register(&gensec_spnego_security_ops);
+	ret = gensec_register(ctx, &gensec_spnego_security_ops);
 	if (!NT_STATUS_IS_OK(ret)) {
 		DEBUG(0,("Failed to register '%s' gensec backend!\n",
 			gensec_spnego_security_ops.name));
diff --git a/auth/ntlmssp/ntlmssp.c b/auth/ntlmssp/ntlmssp.c
index ec2f6d9..cb8f10b 100644
--- a/auth/ntlmssp/ntlmssp.c
+++ b/auth/ntlmssp/ntlmssp.c
@@ -256,14 +256,14 @@ _PUBLIC_ NTSTATUS gensec_ntlmssp_init(TALLOC_CTX *ctx)
 {
 	NTSTATUS ret;
 
-	ret = gensec_register(&gensec_ntlmssp_security_ops);
+	ret = gensec_register(ctx, &gensec_ntlmssp_security_ops);
 	if (!NT_STATUS_IS_OK(ret)) {
 		DEBUG(0,("Failed to register '%s' gensec backend!\n",
 			gensec_ntlmssp_security_ops.name));
 		return ret;
 	}
 
-	ret = gensec_register(&gensec_ntlmssp_resume_ccache_ops);
+	ret = gensec_register(ctx, &gensec_ntlmssp_resume_ccache_ops);
 	if (!NT_STATUS_IS_OK(ret)) {
 		DEBUG(0,("Failed to register '%s' gensec backend!\n",
 			gensec_ntlmssp_resume_ccache_ops.name));
diff --git a/source4/auth/gensec/gensec_gssapi.c b/source4/auth/gensec/gensec_gssapi.c
index 73a08f1..2b3c56b 100644
--- a/source4/auth/gensec/gensec_gssapi.c
+++ b/source4/auth/gensec/gensec_gssapi.c
@@ -1644,21 +1644,21 @@ _PUBLIC_ NTSTATUS gensec_gssapi_init(TALLOC_CTX *ctx)
 {
 	NTSTATUS ret;
 
-	ret = gensec_register(&gensec_gssapi_spnego_security_ops);
+	ret = gensec_register(ctx, &gensec_gssapi_spnego_security_ops);
 	if (!NT_STATUS_IS_OK(ret)) {
 		DEBUG(0,("Failed to register '%s' gensec backend!\n",
 			gensec_gssapi_spnego_security_ops.name));
 		return ret;
 	}
 
-	ret = gensec_register(&gensec_gssapi_krb5_security_ops);
+	ret = gensec_register(ctx, &gensec_gssapi_krb5_security_ops);
 	if (!NT_STATUS_IS_OK(ret)) {
 		DEBUG(0,("Failed to register '%s' gensec backend!\n",
 			gensec_gssapi_krb5_security_ops.name));
 		return ret;
 	}
 
-	ret = gensec_register(&gensec_gssapi_sasl_krb5_security_ops);
+	ret = gensec_register(ctx, &gensec_gssapi_sasl_krb5_security_ops);
 	if (!NT_STATUS_IS_OK(ret)) {
 		DEBUG(0,("Failed to register '%s' gensec backend!\n",
 			gensec_gssapi_sasl_krb5_security_ops.name));
diff --git a/source4/auth/gensec/gensec_krb5.c b/source4/auth/gensec/gensec_krb5.c
index 4756c84..fdd3823 100644
--- a/source4/auth/gensec/gensec_krb5.c
+++ b/source4/auth/gensec/gensec_krb5.c
@@ -1086,14 +1086,14 @@ _PUBLIC_ NTSTATUS gensec_krb5_init(TALLOC_CTX *ctx)
 {
 	NTSTATUS ret;
 
-	ret = gensec_register(&gensec_krb5_security_ops);
+	ret = gensec_register(ctx, &gensec_krb5_security_ops);
 	if (!NT_STATUS_IS_OK(ret)) {
 		DEBUG(0,("Failed to register '%s' gensec backend!\n",
 			gensec_krb5_security_ops.name));
 		return ret;
 	}
 
-	ret = gensec_register(&gensec_fake_gssapi_krb5_security_ops);
+	ret = gensec_register(ctx, &gensec_fake_gssapi_krb5_security_ops);
 	if (!NT_STATUS_IS_OK(ret)) {
 		DEBUG(0,("Failed to register '%s' gensec backend!\n",
 			gensec_fake_gssapi_krb5_security_ops.name));
diff --git a/source4/lib/http/gensec/basic.c b/source4/lib/http/gensec/basic.c
index 6477863..6077aca 100644
--- a/source4/lib/http/gensec/basic.c
+++ b/source4/lib/http/gensec/basic.c
@@ -127,7 +127,7 @@ _PUBLIC_ NTSTATUS gensec_http_basic_init(TALLOC_CTX *ctx)
 {
 	NTSTATUS status;
 
-	status = gensec_register(&gensec_http_basic_security_ops);
+	status = gensec_register(ctx, &gensec_http_basic_security_ops);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0, ("Failed to register '%s' gensec backend!\n",
 				gensec_http_basic_security_ops.name));
diff --git a/source4/lib/http/gensec/ntlm.c b/source4/lib/http/gensec/ntlm.c
index 391f99f..cc4b0f0 100644
--- a/source4/lib/http/gensec/ntlm.c
+++ b/source4/lib/http/gensec/ntlm.c
@@ -110,7 +110,7 @@ _PUBLIC_ NTSTATUS gensec_http_ntlm_init(TALLOC_CTX *ctx)
 {
 	NTSTATUS status;
 
-	status = gensec_register(&gensec_http_ntlm_security_ops);
+	status = gensec_register(ctx, &gensec_http_ntlm_security_ops);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0, ("Failed to register '%s' gensec backend!\n",
 				gensec_http_ntlm_security_ops.name));
-- 
2.7.4


From 6732eb12853abe7c9ffda4958b939a4139b82bc4 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Thu, 11 May 2017 16:01:59 -0700
Subject: [PATCH 5/7] s4: client: Allocate event context off struct
 smbclient_context *, not talloc_autofree_context().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/client/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source4/client/client.c b/source4/client/client.c
index 9b2115a..e04aa25 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -3415,7 +3415,7 @@ static int do_message_op(const char *netbios_name, const char *desthost,
 	lpcfg_smbcli_options(cmdline_lp_ctx, &smb_options);
 	lpcfg_smbcli_session_options(cmdline_lp_ctx, &smb_session_options);
 
-	ev_ctx = s4_event_context_init(talloc_autofree_context());
+	ev_ctx = s4_event_context_init(ctx);
 
 	DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) );
 
-- 
2.7.4


From a9ed598dd0cb0695d21db911c9a304352ef22268 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Thu, 11 May 2017 16:10:31 -0700
Subject: [PATCH 6/7] s4: cifsdd: Allocate the event context off NULL, not
 talloc_autofree_context().

Ensure it's freed on exit paths.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/client/cifsdd.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/source4/client/cifsdd.c b/source4/client/cifsdd.c
index 980948a..7ab59cd 100644
--- a/source4/client/cifsdd.c
+++ b/source4/client/cifsdd.c
@@ -551,6 +551,7 @@ int main(int argc, const char ** argv)
 	int i;
 	const char ** dd_args;
 	struct tevent_context *ev;
+	int rc;
 
 	poptContext pctx;
 	struct poptOption poptions[] = {
@@ -601,7 +602,7 @@ int main(int argc, const char ** argv)
 		}
 	}
 
-	ev = s4_event_context_init(talloc_autofree_context());
+	ev = s4_event_context_init(NULL);
 
 	gensec_init();
 	dump_args();
@@ -609,22 +610,27 @@ int main(int argc, const char ** argv)
 	if (check_arg_numeric("ibs") == 0 || check_arg_numeric("obs") == 0) {
 		fprintf(stderr, "%s: block sizes must be greater that zero\n",
 				PROGNAME);
+		talloc_free(ev);
 		exit(SYNTAX_EXIT_CODE);
 	}
 
 	if (check_arg_pathname("if") == NULL) {
 		fprintf(stderr, "%s: missing input filename\n", PROGNAME);
+		talloc_free(ev);
 		exit(SYNTAX_EXIT_CODE);
 	}
 
 	if (check_arg_pathname("of") == NULL) {
 		fprintf(stderr, "%s: missing output filename\n", PROGNAME);
+		talloc_free(ev);
 		exit(SYNTAX_EXIT_CODE);
 	}
 
 	CatchSignal(SIGINT, dd_handle_signal);
 	CatchSignal(SIGUSR1, dd_handle_signal);
-	return(copy_files(ev, cmdline_lp_ctx));
+	rc = copy_files(ev, cmdline_lp_ctx);
+	talloc_free(ev);
+	return rc;
 }
 
 /* vim: set sw=8 sts=8 ts=8 tw=79 : */
-- 
2.7.4


From b0801a3859f3d9f6c43b57ac990b6bb90a277a39 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Thu, 11 May 2017 16:15:56 -0700
Subject: [PATCH 7/7] s4: nmblookup: Allocate event context off NULL instead of
 talloc_autofree_context().

It's already correctly freed on exit.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 libcli/nbt/tools/nmblookup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcli/nbt/tools/nmblookup.c b/libcli/nbt/tools/nmblookup.c
index afb81c7..e5fa573 100644
--- a/libcli/nbt/tools/nmblookup.c
+++ b/libcli/nbt/tools/nmblookup.c
@@ -372,7 +372,7 @@ int main(int argc, const char *argv[])
 
 	load_interface_list(NULL, cmdline_lp_ctx, &ifaces);
 
-	ev = s4_event_context_init(talloc_autofree_context());
+	ev = s4_event_context_init(NULL);
 
 	while (poptPeekArg(pc)) {
 		const char *name = poptGetArg(pc);
-- 
2.7.4



More information about the samba-technical mailing list