diff options
author | Karel Zak | 2015-01-29 11:03:49 +0100 |
---|---|---|
committer | Karel Zak | 2015-01-29 11:03:49 +0100 |
commit | 7396bdd46852bc213955fb1df597c2c4e646577a (patch) | |
tree | 619a0d5afda7e0140b6a8c20c005d4b56625ddea /libmount/src/context_umount.c | |
parent | libmount: fix mem leak in do_mount_by_types() [coverity scan] (diff) | |
download | kernel-qcow2-util-linux-7396bdd46852bc213955fb1df597c2c4e646577a.tar.gz kernel-qcow2-util-linux-7396bdd46852bc213955fb1df597c2c4e646577a.tar.xz kernel-qcow2-util-linux-7396bdd46852bc213955fb1df597c2c4e646577a.zip |
libmount: fix possible mem leak in has_utab_entry() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/context_umount.c')
-rw-r--r-- | libmount/src/context_umount.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c index c50b97bfb..2a39a6f46 100644 --- a/libmount/src/context_umount.c +++ b/libmount/src/context_umount.c @@ -169,6 +169,7 @@ static int has_utab_entry(struct libmnt_context *cxt, const char *target) struct libmnt_fs *fs; struct libmnt_iter itr; char *cn = NULL; + int rc = 0; assert(cxt); @@ -191,10 +192,16 @@ static int has_utab_entry(struct libmnt_context *cxt, const char *target) mnt_reset_iter(&itr, MNT_ITER_BACKWARD); while (mnt_table_next_fs(cxt->utab, &itr, &fs) == 0) { - if (mnt_fs_streq_target(fs, cn)) - return 1; + if (mnt_fs_streq_target(fs, cn)) { + rc = 1; + break; + } } - return 0; + + if (!cache) + free(cn); + + return rc; } /* this is umount replacement to mnt_context_apply_fstab(), use |