summaryrefslogtreecommitdiffstats
path: root/libmount/src/context_loopdev.c
diff options
context:
space:
mode:
authorStanislav Brabec2016-07-14 15:28:29 +0200
committerKarel Zak2016-08-03 11:53:28 +0200
commit441cdba95b1344a5bf4ce4f490bce416cc85f7d7 (patch)
treee9607cb69f9445294615c5f0697935801a3fd967 /libmount/src/context_loopdev.c
parenttests: remove unnecessary file (diff)
downloadkernel-qcow2-util-linux-441cdba95b1344a5bf4ce4f490bce416cc85f7d7.tar.gz
kernel-qcow2-util-linux-441cdba95b1344a5bf4ce4f490bce416cc85f7d7.tar.xz
kernel-qcow2-util-linux-441cdba95b1344a5bf4ce4f490bce416cc85f7d7.zip
libmount: Fix possible crash in mnt_context_setup_loopdev()
If loopcxt_init() fails, Iloopcxt_deinit() should not be called. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Diffstat (limited to 'libmount/src/context_loopdev.c')
-rw-r--r--libmount/src/context_loopdev.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libmount/src/context_loopdev.c b/libmount/src/context_loopdev.c
index 836ebc1d3..753063219 100644
--- a/libmount/src/context_loopdev.c
+++ b/libmount/src/context_loopdev.c
@@ -217,7 +217,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
*/
rc = loopcxt_init(&lc, 0);
if (rc)
- goto done;
+ goto done_no_deinit;
if (backing_file && !(loopcxt_find_by_backing_file(&lc,
backing_file, offset, LOOPDEV_FL_OFFSET))) {
DBG(LOOP, ul_debugobj(cxt, "using existing loop device %s",
@@ -234,7 +234,9 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
loopcxt_deinit(&lc);
rc = loopcxt_init(&lc, 0);
- if (rc == 0 && loopval) {
+ if (rc)
+ goto done_no_deinit;
+ if (loopval) {
rc = loopcxt_set_device(&lc, loopval);
if (rc == 0)
loopdev = loopcxt_get_device(&lc);