diff options
author | Karel Zak | 2013-03-25 09:17:52 +0100 |
---|---|---|
committer | Karel Zak | 2013-03-25 09:17:52 +0100 |
commit | 52a285bf4e8d3a78d7211694977f5894a748bdac (patch) | |
tree | a627191990c4fc996758275a5c821702b6957bec /libmount/src | |
parent | build-sys: release++ (v2.23-rc1) (diff) | |
download | kernel-qcow2-util-linux-52a285bf4e8d3a78d7211694977f5894a748bdac.tar.gz kernel-qcow2-util-linux-52a285bf4e8d3a78d7211694977f5894a748bdac.tar.xz kernel-qcow2-util-linux-52a285bf4e8d3a78d7211694977f5894a748bdac.zip |
libmount: umount crashes when trying to umount a non-mountpoint
Reported-by: Mantas Mikulėnas <grawity@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r-- | libmount/src/context_umount.c | 4 | ||||
-rw-r--r-- | libmount/src/fs.c | 3 | ||||
-rw-r--r-- | libmount/src/libmount.h.in | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c index 113c53e07..96ae87ae1 100644 --- a/libmount/src/context_umount.c +++ b/libmount/src/context_umount.c @@ -183,7 +183,7 @@ err: static int lookup_umount_fs(struct libmnt_context *cxt) { const char *tgt; - struct libmnt_fs *fs; + struct libmnt_fs *fs = NULL; int rc; assert(cxt); @@ -198,7 +198,7 @@ static int lookup_umount_fs(struct libmnt_context *cxt) rc = mnt_context_find_umount_fs(cxt, tgt, &fs); if (rc < 0) return rc; - if (!fs) { + if (rc == 1 || !fs) { DBG(CXT, mnt_debug_h(cxt, "umount: cannot find %s in mtab", tgt)); return 0; } diff --git a/libmount/src/fs.c b/libmount/src/fs.c index 96c13d331..bb9006dee 100644 --- a/libmount/src/fs.c +++ b/libmount/src/fs.c @@ -129,6 +129,9 @@ struct libmnt_fs *mnt_copy_fs(struct libmnt_fs *dest, { const struct libmnt_fs *org = dest; + if (!src) + return NULL; + if (!dest) { dest = mnt_new_fs(); if (!dest) diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in index ccd260d98..bb18ba115 100644 --- a/libmount/src/libmount.h.in +++ b/libmount/src/libmount.h.in @@ -318,7 +318,7 @@ extern void mnt_reset_fs(struct libmnt_fs *fs) __ul_attribute__((nonnull)); extern struct libmnt_fs *mnt_copy_fs(struct libmnt_fs *dest, const struct libmnt_fs *src) - __ul_attribute__((nonnull(2), warn_unused_result)); + __ul_attribute__((warn_unused_result)); extern void *mnt_fs_get_userdata(struct libmnt_fs *fs) __ul_attribute__((nonnull)); extern int mnt_fs_set_userdata(struct libmnt_fs *fs, void *data); |