render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
3cf992
From 357fc40405c4967654972ecdf0b210fed885185d Mon Sep 17 00:00:00 2001
3cf992
Message-Id: <357fc40405c4967654972ecdf0b210fed885185d@dist-git>
3cf992
From: Michal Privoznik <mprivozn@redhat.com>
3cf992
Date: Fri, 19 Mar 2021 11:51:58 +0100
3cf992
Subject: [PATCH] RHEL: virdevmapper: Don't leak DIR on OOM in
3cf992
 virDMSanitizepath()
3cf992
MIME-Version: 1.0
3cf992
Content-Type: text/plain; charset=UTF-8
3cf992
Content-Transfer-Encoding: 8bit
3cf992
3cf992
This is a RHEL only patch, because it fixes a small issue in one
3cf992
of backported commits that was basically rewritten from scratch
3cf992
(v4.5.0-400-g6bf725c07c).
3cf992
3cf992
During the rewrite I've introduced a problem, in which opened
3cf992
/dev/mapper/ directory can leak if OOM happened afterwards.
3cf992
3cf992
Fixes: 6bf725c07c25b56937c494b6c7e83e6ca27ec54c
3cf992
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1933557
3cf992
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
3cf992
Message-Id: <c3ba31ab36478ea466128572aa53498555c7995f.1616151101.git.mprivozn@redhat.com>
3cf992
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3cf992
---
3cf992
 src/util/virdevmapper.c | 3 ++-
3cf992
 1 file changed, 2 insertions(+), 1 deletion(-)
3cf992
3cf992
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
3cf992
index dcb3c08df5..33cde6ca0c 100644
3cf992
--- a/src/util/virdevmapper.c
3cf992
+++ b/src/util/virdevmapper.c
3cf992
@@ -216,7 +216,7 @@ virDMSanitizepath(const char *path)
3cf992
         VIR_AUTOFREE(char *) tmp = NULL;
3cf992
 
3cf992
         if (virAsprintf(&tmp, DEV_DM_DIR "/%s", ent->d_name) < 0)
3cf992
-            return NULL;
3cf992
+            goto cleanup;
3cf992
 
3cf992
         if (stat(tmp, &sb[1]) == 0 &&
3cf992
             sb[0].st_rdev == sb[1].st_rdev) {
3cf992
@@ -225,6 +225,7 @@ virDMSanitizepath(const char *path)
3cf992
         }
3cf992
     }
3cf992
 
3cf992
+ cleanup:
3cf992
     virDirClose(&dh);
3cf992
     return ret;
3cf992
 }
3cf992
-- 
3cf992
2.31.0
3cf992