File util-linux-loop-reuse-01.patch of Package util-linux.4768

From 441cdba95b1344a5bf4ce4f490bce416cc85f7d7 Mon Sep 17 00:00:00 2001
From: Stanislav Brabec <sbrabec@suse.cz>
Date: Thu, 14 Jul 2016 15:28:29 +0200
Subject: [PATCH 1/20] 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>
---
 libmount/src/context_loopdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: util-linux-2.28/libmount/src/context_loopdev.c
===================================================================
--- util-linux-2.28.orig/libmount/src/context_loopdev.c
+++ util-linux-2.28/libmount/src/context_loopdev.c
@@ -217,7 +217,7 @@ int mnt_context_setup_loopdev(struct lib
 	*/
 	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(CXT, ul_debugobj(cxt, "using existing loop device %s",
@@ -234,7 +234,9 @@ int mnt_context_setup_loopdev(struct lib
 	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);
openSUSE Build Service is sponsored by