]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: cleanup libmnt_fs list after mnt_table_remove_fs()
authorKarel Zak <kzak@redhat.com>
Thu, 22 Aug 2013 09:57:06 +0000 (11:57 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 22 Aug 2013 09:57:06 +0000 (11:57 +0200)
.. otherwise mnt_free_fs() will try to remove FS from non-existing
list.

Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/fs.c
libmount/src/tab.c

index 690428cdab9550fb31b60ac7a76159b85461ebb1..23c873d541152abfc65571535a4d08cdad666cc5 100644 (file)
@@ -34,6 +34,7 @@ struct libmnt_fs *mnt_new_fs(void)
 
        fs->refcount = 1;
        INIT_LIST_HEAD(&fs->ents);
+       /*DBG(FS, mnt_debug_h(fs, "alloc"));*/
        return fs;
 }
 
@@ -89,6 +90,7 @@ void mnt_reset_fs(struct libmnt_fs *fs)
 
        ref = fs->refcount;
        memset(fs, 0, sizeof(*fs));
+       INIT_LIST_HEAD(&fs->ents);
        fs->refcount = ref;
 }
 
@@ -295,7 +297,12 @@ err:
 void *mnt_fs_get_userdata(struct libmnt_fs *fs)
 {
        assert(fs);
-       return fs ? fs->userdata : NULL;
+
+       if (!fs)
+               return NULL;
+
+       /*DBG(FS, mnt_debug_h(fs, "get userdata [%p]", fs->userdata));*/
+       return fs->userdata;
 }
 
 /**
@@ -312,6 +319,8 @@ int mnt_fs_set_userdata(struct libmnt_fs *fs, void *data)
        assert(fs);
        if (!fs)
                return -EINVAL;
+
+       /*DBG(FS, mnt_debug_h(fs, "set userdata [%p]", fs->userdata));*/
        fs->userdata = data;
        return 0;
 }
index b1078cf818c5e45b8d74169c151f0a6d03fceb7d..d646d6a83db8225b4d63457d6285b6172d7883c9 100644 (file)
@@ -455,7 +455,10 @@ int mnt_table_remove_fs(struct libmnt_table *tb, struct libmnt_fs *fs)
 
        if (!tb || !fs)
                return -EINVAL;
+
        list_del(&fs->ents);
+       INIT_LIST_HEAD(&fs->ents);      /* otherwise FS still points to the list */
+
        mnt_unref_fs(fs);
        tb->nents--;
        return 0;