]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: check table membership before adding entry
authorTim Hildering <hilderingt@posteo.net>
Sun, 17 Feb 2019 23:01:18 +0000 (00:01 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 18 Feb 2019 10:50:52 +0000 (11:50 +0100)
Added validation to function 'mnt_table_add_fs()' to check that added @fs
is not already a member of another table.

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

index d80fb0579b74058daafe4ba7fcbdad5276837b20..7f08730edcd2f64e450abf02fdcb0ecd3314932c 100644 (file)
@@ -411,6 +411,9 @@ int mnt_table_add_fs(struct libmnt_table *tb, struct libmnt_fs *fs)
        if (!tb || !fs)
                return -EINVAL;
 
+       if (!list_empty(&fs->ents))
+               return -EBUSY;
+
        mnt_ref_fs(fs);
        list_add_tail(&fs->ents, &tb->ents);
        tb->nents++;