summaryrefslogtreecommitdiffstats
path: root/libmount
diff options
context:
space:
mode:
authorKarel Zak2019-05-15 17:25:04 +0200
committerKarel Zak2019-05-15 17:25:04 +0200
commitcb400752a4114c0c904c20253ed5ee68c11dc326 (patch)
tree37f1e5704b5b2feb5f5cd8b59ae7977978f50f01 /libmount
parentlibfdisk: avoid memory leak [coverity scan] (diff)
downloadkernel-qcow2-util-linux-cb400752a4114c0c904c20253ed5ee68c11dc326.tar.gz
kernel-qcow2-util-linux-cb400752a4114c0c904c20253ed5ee68c11dc326.tar.xz
kernel-qcow2-util-linux-cb400752a4114c0c904c20253ed5ee68c11dc326.zip
libmount: fix memory leak on error [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount')
-rw-r--r--libmount/src/context_umount.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c
index 7c5893ae6..999cdb016 100644
--- a/libmount/src/context_umount.c
+++ b/libmount/src/context_umount.c
@@ -574,9 +574,10 @@ static int evaluate_permissions(struct libmnt_context *cxt)
curr_user = mnt_get_username(getuid());
- if (!mnt_context_switch_ns(cxt, ns_old))
+ if (!mnt_context_switch_ns(cxt, ns_old)) {
+ free(curr_user);
return -MNT_ERR_NAMESPACE;
-
+ }
if (!curr_user) {
DBG(CXT, ul_debugobj(cxt, "umount %s: cannot "
"convert %d to username", tgt, getuid()));