]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: don't refer optlist when copy libmnt_fs
authorKarel Zak <kzak@redhat.com>
Thu, 6 Oct 2022 10:00:57 +0000 (12:00 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Jan 2023 11:58:42 +0000 (12:58 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/fs.c

index c7858898a40f17db2587768315ae1d63e6f58221..5e5d6dc289bb8d6f181d02bdbee4d5799596aa10 100644 (file)
@@ -59,8 +59,6 @@ void mnt_free_fs(struct libmnt_fs *fs)
 
        DBG(FS, ul_debugobj(fs, "free [refcount=%d]", fs->refcount));
 
-       mnt_unref_optlist(fs->optlist);
-
        mnt_reset_fs(fs);
        free(fs);
 }
@@ -97,6 +95,9 @@ void mnt_reset_fs(struct libmnt_fs *fs)
        free(fs->opt_fields);
        free(fs->comment);
 
+       mnt_unref_optlist(fs->optlist);
+       fs->optlist = NULL;
+
        fs->opts_age = 0;
 
        memset(fs, 0, sizeof(*fs));
@@ -236,7 +237,7 @@ int mnt_fs_follow_optlist(struct libmnt_fs *fs, struct libmnt_optlist *ol)
  * set, then the field is NOT overwritten.
  *
  * This function does not copy userdata (se mnt_fs_set_userdata()). A new copy is
- * not linked with any existing mnt_tab.
+ * not linked with any existing mnt_tab or optlist.
  *
  * Returns: @dest or NULL in case of error
  */
@@ -294,10 +295,6 @@ struct libmnt_fs *mnt_copy_fs(struct libmnt_fs *dest,
        dest->usedsize   = src->usedsize;
        dest->priority   = src->priority;
 
-       dest->opts_age   = src->opts_age;
-       dest->optlist    = src->optlist;
-       mnt_ref_optlist(dest->optlist);
-
        return dest;
 err:
        if (!org)