*Resend with hopefully non mangled patches* References: <20140220131958.965092001@xxxxxxxxxxxxxxxxxx> Content-Disposition: inline; filename=fio-fix-cloneleak.diff From: Christian Ehrhardt <ehrhardt@xxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxx> --- [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; -- To unsubscribe from this list: send the line "unsubscribe fio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html