* [patch 1/9] fio: fix job clone mem leak
[not found] <20140219143639.168501090@linux.vnet.ibm.com>
@ 2014-02-19 15:12 ` Christian Ehrhardt
0 siblings, 0 replies; 2+ messages in thread
From: Christian Ehrhardt @ 2014-02-19 15:12 UTC (permalink / raw)
To: fio; +Cc: oberpar, Christian Ehrhardt
From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
In the loop to create clones at the bottom of add_job the function
get_new_job
clones the thread_data, just to occaisonally get the allocated pointers for
filename and files overwritten a few lines later.
The dup files also duplicates the name strings so the references to
these are
lost by the setting to null.
This patch fixes takes care of that and frees the memory before
discarding the
pointers (found via valgrind).
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
---
[diffstat]
init.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
[diff]
--- a/init.c
+++ b/init.c
@@ -1118,10 +1118,21 @@ static int add_job(struct thread_data *t
td_new->o.new_group = 0;
if (file_alloced) {
- td_new->o.filename = NULL;
td_new->files_index = 0;
td_new->files_size = 0;
- td_new->files = NULL;
+ if (td_new->files) {
+ struct fio_file *f;
+ for_each_file(td_new, f, i) {
+ if (f->file_name)
+ free(f->file_name);
+ free(f);
+ }
+ td_new->files = NULL;
+ }
+ if (td_new->o.filename) {
+ free(td_new->o.filename);
+ td_new->o.filename = NULL;
+ }
}
job_add_num = numjobs - 1;
^ permalink raw reply [flat|nested] 2+ messages in thread
* [patch 1/9] fio: fix job clone mem leak
@ 2014-02-20 13:19 ehrhardt
0 siblings, 0 replies; 2+ messages in thread
From: ehrhardt @ 2014-02-20 13:19 UTC (permalink / raw)
To: fio; +Cc: oberpar, Christian Ehrhardt
*Resend with hopefully non mangled patches*
References: <20140220131958.965092001@linux.vnet.ibm.com>
Content-Disposition: inline; filename=fio-fix-cloneleak.diff
From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
In the loop to create clones at the bottom of add_job the function get_new_job
clones the thread_data, just to occaisonally get the allocated pointers for
filename and files overwritten a few lines later.
The dup files also duplicates the name strings so the references to these are
lost by the setting to null.
This patch fixes takes care of that and frees the memory before discarding the
pointers (found via valgrind).
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
---
[diffstat]
init.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
[diff]
--- a/init.c
+++ b/init.c
@@ -1118,10 +1118,21 @@ static int add_job(struct thread_data *t
td_new->o.new_group = 0;
if (file_alloced) {
- td_new->o.filename = NULL;
td_new->files_index = 0;
td_new->files_size = 0;
- td_new->files = NULL;
+ if (td_new->files) {
+ struct fio_file *f;
+ for_each_file(td_new, f, i) {
+ if (f->file_name)
+ free(f->file_name);
+ free(f);
+ }
+ td_new->files = NULL;
+ }
+ if (td_new->o.filename) {
+ free(td_new->o.filename);
+ td_new->o.filename = NULL;
+ }
}
job_add_num = numjobs - 1;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-20 13:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-20 13:19 [patch 1/9] fio: fix job clone mem leak ehrhardt
[not found] <20140219143639.168501090@linux.vnet.ibm.com>
2014-02-19 15:12 ` Christian Ehrhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox