]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: (verity) fix deinitialization
authorKarel Zak <kzak@redhat.com>
Mon, 26 May 2025 15:57:34 +0000 (17:57 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 26 May 2025 16:21:25 +0000 (18:21 +0200)
Fixes: https://github.com/util-linux/util-linux/issues/3592
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/hook_veritydev.c

index 5bb58d0903c635fda637e015244b18027172ba74..12c63089714451a9dd4c082decb77c42eb42f768 100644 (file)
@@ -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;
 }