From 20da5d5286feb70737c5f6bc2ea000f79be0457a Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Sat, 11 May 2019 14:24:24 +1000 Subject: [PATCH 1/3] ctdb-recoverd: Fix memory leak state is always freed before exiting this function, so allocate fde off it instead of long-lived ctdb context. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13943 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit 6a2941e2a9fd6ab2d5b8dbac042b61a7b1b0b914) --- ctdb/server/ctdb_recoverd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index 9b3559b2a92..3e63bd1e7a5 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -1134,7 +1134,7 @@ static int helper_run(struct ctdb_recoverd *rec, TALLOC_CTX *mem_ctx, state->done = false; - fde = tevent_add_fd(rec->ctdb->ev, rec->ctdb, state->fd[0], + fde = tevent_add_fd(rec->ctdb->ev, state, state->fd[0], TEVENT_FD_READ, helper_handler, state); if (fde == NULL) { goto fail; -- 2.20.1 From 9cc73c26903b4d555fb5332f6e7a88f59cec7fd8 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Sat, 11 May 2019 17:33:57 +1000 Subject: [PATCH 2/3] ctdb-common: Fix memory leak BUG: https://bugzilla.samba.org/show_bug.cgi?id=13943 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit 30bc6e2529cdd444d4ec7902844c3a6fb0858090) --- ctdb/common/event_script.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ctdb/common/event_script.c b/ctdb/common/event_script.c index 8978d1452c0..8bdfdd0b5ca 100644 --- a/ctdb/common/event_script.c +++ b/ctdb/common/event_script.c @@ -117,7 +117,8 @@ int event_script_get_list(TALLOC_CTX *mem_ctx, } *out = script_list; - return 0; + ret = 0; + goto done; nomem: ret = ENOMEM; -- 2.20.1 From 567bfa62066981ada6e37d8ce83c143854989c42 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 13 May 2019 17:07:59 +1000 Subject: [PATCH 3/3] ctdb-common: Fix memory leak in run_proc BUG: https://bugzilla.samba.org/show_bug.cgi?id=13943 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Tue May 14 08:59:03 UTC 2019 on sn-devel-184 (cherry picked from commit b1f4c86eea022999d5439e4a6ef3494fe41479b6) --- ctdb/common/run_proc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ctdb/common/run_proc.c b/ctdb/common/run_proc.c index 037b6d9651d..0c3c1de72fe 100644 --- a/ctdb/common/run_proc.c +++ b/ctdb/common/run_proc.c @@ -302,13 +302,15 @@ again: proc->fd = -1; } + DLIST_REMOVE(run_ctx->plist, proc); + /* Active run_proc request */ if (proc->req != NULL) { run_proc_done(proc->req); + } else { + talloc_free(proc); } - DLIST_REMOVE(run_ctx->plist, proc); - goto again; } @@ -426,6 +428,7 @@ static void run_proc_done(struct tevent_req *req) if (state->proc->output != NULL) { state->output = talloc_steal(state, state->proc->output); } + talloc_steal(state, state->proc); tevent_req_done(req); } -- 2.20.1