qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 080/109] virtiofsd: fix memory leak on lo.source


From: Dr. David Alan Gilbert (git)
Subject: [PATCH v2 080/109] virtiofsd: fix memory leak on lo.source
Date: Tue, 21 Jan 2020 12:24:04 +0000

From: Liu Bo <address@hidden>

valgrind reported that lo.source is leaked on quiting, but it was defined
as (const char*) as it may point to a const string "/".

Signed-off-by: Liu Bo <address@hidden>
---
 tools/virtiofsd/passthrough_ll.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 4e01a37ddb..462c250382 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -115,7 +115,7 @@ struct lo_data {
     int writeback;
     int flock;
     int xattr;
-    const char *source;
+    char *source;
     double timeout;
     int cache;
     int timeout_set;
@@ -2497,9 +2497,8 @@ int main(int argc, char *argv[])
             fuse_log(FUSE_LOG_ERR, "source is not a directory\n");
             exit(1);
         }
-
     } else {
-        lo.source = "/";
+        lo.source = strdup("/");
     }
     if (!lo.timeout_set) {
         switch (lo.cache) {
@@ -2570,5 +2569,7 @@ err_out1:
         close(lo.root.fd);
     }
 
+    free(lo.source);
+
     return ret ? 1 : 0;
 }
-- 
2.24.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]