Blame 0088-virtiofsd-fix-memory-leak-on-lo.source.patch
|
|
1d442b |
From: Liu Bo <bo.liu@linux.alibaba.com>
|
|
|
1d442b |
Date: Mon, 27 Jan 2020 19:01:57 +0000
|
|
|
1d442b |
Subject: [PATCH] virtiofsd: fix memory leak on lo.source
|
|
|
1d442b |
|
|
|
1d442b |
valgrind reported that lo.source is leaked on quiting, but it was defined
|
|
|
1d442b |
as (const char*) as it may point to a const string "/".
|
|
|
1d442b |
|
|
|
1d442b |
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
|
|
|
1d442b |
Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
|
|
|
1d442b |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
1d442b |
(cherry picked from commit eb68a33b5fc5dde87bd9b99b94e7c33a5d8ea82e)
|
|
|
1d442b |
---
|
|
|
1d442b |
tools/virtiofsd/passthrough_ll.c | 7 ++++---
|
|
|
1d442b |
1 file changed, 4 insertions(+), 3 deletions(-)
|
|
|
1d442b |
|
|
|
1d442b |
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
|
|
|
1d442b |
index af050c6d97..056ebe8556 100644
|
|
|
1d442b |
--- a/tools/virtiofsd/passthrough_ll.c
|
|
|
1d442b |
+++ b/tools/virtiofsd/passthrough_ll.c
|
|
|
1d442b |
@@ -115,7 +115,7 @@ struct lo_data {
|
|
|
1d442b |
int writeback;
|
|
|
1d442b |
int flock;
|
|
|
1d442b |
int xattr;
|
|
|
1d442b |
- const char *source;
|
|
|
1d442b |
+ char *source;
|
|
|
1d442b |
double timeout;
|
|
|
1d442b |
int cache;
|
|
|
1d442b |
int timeout_set;
|
|
|
1d442b |
@@ -2497,9 +2497,8 @@ int main(int argc, char *argv[])
|
|
|
1d442b |
fuse_log(FUSE_LOG_ERR, "source is not a directory\n");
|
|
|
1d442b |
exit(1);
|
|
|
1d442b |
}
|
|
|
1d442b |
-
|
|
|
1d442b |
} else {
|
|
|
1d442b |
- lo.source = "/";
|
|
|
1d442b |
+ lo.source = strdup("/");
|
|
|
1d442b |
}
|
|
|
1d442b |
if (!lo.timeout_set) {
|
|
|
1d442b |
switch (lo.cache) {
|
|
|
1d442b |
@@ -2570,5 +2569,7 @@ err_out1:
|
|
|
1d442b |
close(lo.root.fd);
|
|
|
1d442b |
}
|
|
|
1d442b |
|
|
|
1d442b |
+ free(lo.source);
|
|
|
1d442b |
+
|
|
|
1d442b |
return ret ? 1 : 0;
|
|
|
1d442b |
}
|