From b3a18d66c00dba73a3f56a6f95781b4d34db1fe2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 2 Jun 2015 12:43:17 +0200 Subject: [PATCH] ctdb-locking: move all auto_mark logic into process_callbacks() The caller should not dereference lock_ctx after invoking process_callbacks(), it might be destroyed already. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11293 Signed-off-by: Stefan Metzmacher Reviewed-by: Amitay Isaacs Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Fri Jun 12 15:28:57 CEST 2015 on sn-devel-104 --- ctdb/server/ctdb_lock.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c index 6a79e209232..82295ea5dcb 100644 --- a/ctdb/server/ctdb_lock.c +++ b/ctdb/server/ctdb_lock.c @@ -392,6 +392,8 @@ static void process_callbacks(struct lock_context *lock_ctx, bool locked) break; } } + + talloc_free(lock_ctx); } @@ -437,7 +439,6 @@ static void ctdb_lock_handler(struct tevent_context *ev, void *private_data) { struct lock_context *lock_ctx; - TALLOC_CTX *tmp_ctx = NULL; char c; bool locked; double t; @@ -451,11 +452,6 @@ static void ctdb_lock_handler(struct tevent_context *ev, t = timeval_elapsed(&lock_ctx->start_time); id = lock_bucket_id(t); - if (lock_ctx->auto_mark) { - tmp_ctx = talloc_new(ev); - talloc_steal(tmp_ctx, lock_ctx); - } - /* Read the status from the child process */ if (sys_read(lock_ctx->fd[0], &c, 1) != 1) { locked = false; @@ -487,10 +483,6 @@ static void ctdb_lock_handler(struct tevent_context *ev, } process_callbacks(lock_ctx, locked); - - if (lock_ctx->auto_mark) { - talloc_free(tmp_ctx); - } }