From: Martin Schwenke Date: Mon, 13 Jan 2020 10:13:32 +0000 (+1100) Subject: ctdb-daemon: Only stop monitoring if it has been initialised X-Git-Tag: ldb-2.1.1~236 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d79e2dcfc84d937db3c6eb3d17520aaf6e7bba4c;p=thirdparty%2Fsamba.git ctdb-daemon: Only stop monitoring if it has been initialised This avoids a crash if ctdb_shutdown_sequence() is called before monitoring is initialised. Switch to using TALLOC_FREE() while touching this function. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/server/ctdb_monitor.c b/ctdb/server/ctdb_monitor.c index cfa3a6a1bfa..5c694bde969 100644 --- a/ctdb/server/ctdb_monitor.c +++ b/ctdb/server/ctdb_monitor.c @@ -416,8 +416,12 @@ static void ctdb_check_health(struct tevent_context *ev, */ void ctdb_stop_monitoring(struct ctdb_context *ctdb) { - talloc_free(ctdb->monitor->monitor_context); - ctdb->monitor->monitor_context = NULL; + if (ctdb->monitor == NULL) { + D_NOTICE("Monitoring not yet initialised\n"); + return; + } + + TALLOC_FREE(ctdb->monitor->monitor_context); ctdb->monitor->next_interval = 5; DEBUG(DEBUG_NOTICE,("Monitoring has been stopped\n"));