thebeanogamer / rpms / qemu-kvm

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