cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
902636
From 9e0f5b64f30c2f841f297e25c2f3a6d82c8a16b8 Mon Sep 17 00:00:00 2001
902636
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
902636
Date: Mon, 27 Jan 2020 19:01:57 +0100
902636
Subject: [PATCH 086/116] virtiofsd: fix memory leak on lo.source
902636
MIME-Version: 1.0
902636
Content-Type: text/plain; charset=UTF-8
902636
Content-Transfer-Encoding: 8bit
902636
902636
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
Message-id: <20200127190227.40942-83-dgilbert@redhat.com>
902636
Patchwork-id: 93536
902636
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 082/112] virtiofsd: fix memory leak on lo.source
902636
Bugzilla: 1694164
902636
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
902636
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
902636
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
902636
902636
From: Liu Bo <bo.liu@linux.alibaba.com>
902636
902636
valgrind reported that lo.source is leaked on quiting, but it was defined
902636
as (const char*) as it may point to a const string "/".
902636
902636
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
902636
Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
902636
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
(cherry picked from commit eb68a33b5fc5dde87bd9b99b94e7c33a5d8ea82e)
902636
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
902636
---
902636
 tools/virtiofsd/passthrough_ll.c | 7 ++++---
902636
 1 file changed, 4 insertions(+), 3 deletions(-)
902636
902636
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
902636
index af050c6..056ebe8 100644
902636
--- a/tools/virtiofsd/passthrough_ll.c
902636
+++ b/tools/virtiofsd/passthrough_ll.c
902636
@@ -115,7 +115,7 @@ struct lo_data {
902636
     int writeback;
902636
     int flock;
902636
     int xattr;
902636
-    const char *source;
902636
+    char *source;
902636
     double timeout;
902636
     int cache;
902636
     int timeout_set;
902636
@@ -2497,9 +2497,8 @@ int main(int argc, char *argv[])
902636
             fuse_log(FUSE_LOG_ERR, "source is not a directory\n");
902636
             exit(1);
902636
         }
902636
-
902636
     } else {
902636
-        lo.source = "/";
902636
+        lo.source = strdup("/");
902636
     }
902636
     if (!lo.timeout_set) {
902636
         switch (lo.cache) {
902636
@@ -2570,5 +2569,7 @@ err_out1:
902636
         close(lo.root.fd);
902636
     }
902636
 
902636
+    free(lo.source);
902636
+
902636
     return ret ? 1 : 0;
902636
 }
902636
-- 
902636
1.8.3.1
902636