diff options
author | Karel Zak | 2015-01-29 10:58:55 +0100 |
---|---|---|
committer | Karel Zak | 2015-01-29 10:58:55 +0100 |
commit | 7bc2fd3d2368c88c26ddc43e5f6dd3f9ac1c488d (patch) | |
tree | 26bf9d32793c871210fbe4a96e5fa2cc79902dfa /libmount/src | |
parent | libfdisk: make fdisk_partition_to_string() more robust [coverity scan] (diff) | |
download | kernel-qcow2-util-linux-7bc2fd3d2368c88c26ddc43e5f6dd3f9ac1c488d.tar.gz kernel-qcow2-util-linux-7bc2fd3d2368c88c26ddc43e5f6dd3f9ac1c488d.tar.xz kernel-qcow2-util-linux-7bc2fd3d2368c88c26ddc43e5f6dd3f9ac1c488d.zip |
libmount: fix mem leak in do_mount_by_types() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r-- | libmount/src/context.c | 9 | ||||
-rw-r--r-- | libmount/src/context_mount.c | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/libmount/src/context.c b/libmount/src/context.c index f623f34a7..dff7a47fd 100644 --- a/libmount/src/context.c +++ b/libmount/src/context.c @@ -1647,8 +1647,9 @@ int mnt_context_prepare_target(struct libmnt_context *cxt) return 0; } -/* Guess type, but not set to cxt->fs, use free() for the result. It's no error - * when we're not able to guess a filesystem type. +/* Guess type, but not set to cxt->fs, always use free() for the result. It's + * no error when we're not able to guess a filesystem type. Note that error + * does not mean that result in @type is NULL. */ int mnt_context_guess_srcpath_fstype(struct libmnt_context *cxt, char **type) { @@ -1717,8 +1718,8 @@ int mnt_context_guess_fstype(struct libmnt_context *cxt) rc = mnt_context_guess_srcpath_fstype(cxt, &type); if (rc == 0 && type) __mnt_fs_set_fstype_ptr(cxt->fs, type); - else - free(type); + + free(type); done: DBG(CXT, ul_debugobj(cxt, "FS type: %s [rc=%d]", mnt_fs_get_fstype(cxt->fs), rc)); diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index 71a4e85f9..455ef2ef0 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -787,8 +787,9 @@ static int do_mount_by_types(struct libmnt_context *cxt, const char *types) if (strcmp(p, "auto") == 0) { rc = mnt_context_guess_srcpath_fstype(cxt, &autotype); if (rc) { - DBG(CXT, ul_debugobj(cxt, "failed to guess FS type")); + DBG(CXT, ul_debugobj(cxt, "failed to guess FS type [rc=%d]", rc)); free(p0); + free(autotype); return rc; } p = autotype; |