qemu-devel
[Top][All Lists]
Advanced

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

[PATCH 079/104] virtiofsd: fix memory leak on lo.source


From: Dr. David Alan Gilbert (git)
Subject: [PATCH 079/104] virtiofsd: fix memory leak on lo.source
Date: Thu, 12 Dec 2019 16:38:39 +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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 33092de65a..45cf466178 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -2529,9 +2529,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("/");
     }
     lo.root.is_symlink = false;
     if (!lo.timeout_set) {
@@ -2610,5 +2609,7 @@ err_out1:
         close(lo.root.fd);
     }
 
+    free((char *)lo.source);
+
     return ret ? 1 : 0;
 }
-- 
2.23.0




reply via email to

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