From ad753da08d20dbc7c069d623c6e55da480d54d69 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 26 Aug 2025 09:50:04 +0200 Subject: [PATCH] lib: Re-add dlclose(handle) when module initialization failed Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Mon Sep 1 17:04:27 UTC 2025 on atb-devel-224 --- lib/util/modules.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/util/modules.c b/lib/util/modules.c index cafc73d6259..b8d6e4cfcd1 100644 --- a/lib/util/modules.c +++ b/lib/util/modules.c @@ -151,6 +151,7 @@ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *subsystem) static NTSTATUS load_module_absolute_path(const char *module_path, bool is_probe) { + void *handle = NULL; init_module_fn init; NTSTATUS status; @@ -158,7 +159,7 @@ static NTSTATUS load_module_absolute_path(const char *module_path, is_probe ? "Probing" : "Loading", module_path); - init = load_module(module_path, is_probe, NULL); + init = load_module(module_path, is_probe, &handle); if (init == NULL) { return NT_STATUS_UNSUCCESSFUL; } @@ -170,6 +171,7 @@ static NTSTATUS load_module_absolute_path(const char *module_path, DBG_ERR("Module '%s' initialization failed: %s\n", module_path, get_friendly_nt_error_msg(status)); + dlclose(handle); return status; } -- 2.47.3