From e952fa1db601505b67740435c5b0a2d6637d49c7 Mon Sep 17 00:00:00 2001 From: snordmann Date: Tue, 8 Aug 2023 13:31:13 +0300 Subject: [PATCH] TL/SHARP: fix ctx create epilog cleanup --- src/components/tl/sharp/tl_sharp_context.c | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/components/tl/sharp/tl_sharp_context.c b/src/components/tl/sharp/tl_sharp_context.c index 7430eeb067..03d914d8e2 100644 --- a/src/components/tl/sharp/tl_sharp_context.c +++ b/src/components/tl/sharp/tl_sharp_context.c @@ -442,24 +442,22 @@ ucc_status_t ucc_tl_sharp_context_create_epilog(ucc_base_context_t *context) status = ucc_topo_init(set, core_ctx->topo, &topo); if (UCC_OK != status) { tl_error(sharp_ctx->super.super.lib, "failed to init topo"); - return status; + goto err_topo_init; } status = ucc_tl_sharp_context_init(sharp_ctx, &sharp_ctx->sharp_context, &sharp_ctx->oob_ctx, topo); + ucc_topo_cleanup(topo); if (status != UCC_OK) { - ucc_topo_cleanup(topo); - return status; + goto err_sharp_ctx_init; } - ucc_topo_cleanup(topo); - if (sharp_ctx->cfg.use_rcache) { status = ucc_tl_sharp_rcache_create(sharp_ctx->sharp_context, &sharp_ctx->rcache); if (status != UCC_OK) { tl_error(sharp_ctx->super.super.lib, "failed to create rcache"); - sharp_coll_finalize(sharp_ctx->sharp_context); - return UCC_ERR_NO_RESOURCE; + status = UCC_ERR_NO_RESOURCE; + goto err_sharp_ctx_init; } } @@ -468,10 +466,20 @@ ucc_status_t ucc_tl_sharp_context_create_epilog(ucc_base_context_t *context) sharp_ctx->sharp_context); if (status != UCC_OK) { tl_error(context->lib, "failed to register progress function"); - return status; + goto err_sharp_progress_register; } return UCC_OK; + +err_sharp_progress_register: + if (self->rcache != NULL) { + ucc_rcache_destroy(self->rcache); + } +err_sharp_ctx_init: + sharp_coll_finalize(sharp_ctx->sharp_context); +err_topo_init: + ucc_mpool_cleanup(&sharp_ctx->req_mp, 1); + return status; } UCC_CLASS_CLEANUP_FUNC(ucc_tl_sharp_context_t)