From: Karel Zak Date: Wed, 12 Oct 2022 10:23:37 +0000 (+0200) Subject: libmount: improve context deinitialization X-Git-Tag: v2.39-rc1~237 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=181397430ae1fd8c8c5d4ad46db731864dfbffbf;p=thirdparty%2Futil-linux.git libmount: improve context deinitialization Signed-off-by: Karel Zak --- diff --git a/libmount/src/context.c b/libmount/src/context.c index 3551b0d77b..96f43d58dc 100644 --- a/libmount/src/context.c +++ b/libmount/src/context.c @@ -110,11 +110,10 @@ void mnt_free_context(struct libmnt_context *cxt) mnt_free_update(cxt->update); mnt_context_set_target_ns(cxt, NULL); - mnt_context_deinit_hooksets(cxt); free(cxt->children); - DBG(CXT, ul_debugobj(cxt, "<---- free")); + DBG(CXT, ul_debugobj(cxt, "free")); free(cxt); } @@ -232,12 +231,15 @@ int mnt_context_apply_template(struct libmnt_context *cxt) if (!cxt) return -EINVAL; - DBG(CXT, ul_debugobj(cxt, "restoring template")); - mnt_unref_optlist(cxt->optlist); - cxt->optlist = NULL; + if (cxt->optlist) { + mnt_unref_optlist(cxt->optlist); + cxt->optlist = NULL; + } - if (cxt->optlist_saved) + if (cxt->optlist_saved) { + DBG(CXT, ul_debugobj(cxt, "restoring template")); cxt->optlist = mnt_copy_optlist(cxt->optlist_saved); + } return 0; } @@ -1974,6 +1976,8 @@ int mnt_context_prepare_helper(struct libmnt_context *cxt, const char *name, assert(cxt->fs); assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED)); + DBG(CXT, ul_debugobj(cxt, "checking for helper")); + if (cxt->helper) { free(cxt->helper); cxt->helper = NULL; diff --git a/libmount/src/hooks.c b/libmount/src/hooks.c index ef52827692..7b1ab7f5a2 100644 --- a/libmount/src/hooks.c +++ b/libmount/src/hooks.c @@ -92,9 +92,6 @@ int mnt_context_deinit_hooksets(struct libmnt_context *cxt) assert(cxt); - if (list_empty(&cxt->hooksets_hooks)) - return 0; - for (i = 0; i < ARRAY_SIZE(hooksets); i++) { const struct libmnt_hookset *hs = hooksets[i];