From: Karel Zak Date: Mon, 26 May 2025 15:57:34 +0000 (+0200) Subject: libmount: (verity) fix deinitialization X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=09a306d6528581a4f3ecbeedf315108f99c872c3;p=thirdparty%2Futil-linux.git libmount: (verity) fix deinitialization Fixes: https://github.com/util-linux/util-linux/issues/3592 Signed-off-by: Karel Zak --- diff --git a/libmount/src/hook_veritydev.c b/libmount/src/hook_veritydev.c index 5bb58d090..12c630897 100644 --- a/libmount/src/hook_veritydev.c +++ b/libmount/src/hook_veritydev.c @@ -180,9 +180,13 @@ static struct hookset_data *new_hookset_data( struct libmnt_context *cxt, const struct libmnt_hookset *hs) { - struct hookset_data *hsd = calloc(1, sizeof(struct hookset_data)); + struct hookset_data *hsd; + + hsd = calloc(1, sizeof(struct hookset_data)); + if (!hsd) + return NULL; - if (hsd && mnt_context_set_hookset_data(cxt, hs, hsd) != 0) + if (mnt_context_set_hookset_data(cxt, hs, hsd) != 0) goto failed; #ifdef CRYPTSETUP_VIA_DLOPEN @@ -196,7 +200,10 @@ static struct hookset_data *new_hookset_data( return hsd; failed: - free(hsd); + if (mnt_context_get_hookset_data(cxt, hs)) + free_hookset_data(cxt, hs); + else + free(hsd); return NULL; }