init: add_job() needs to use right file freeing functions
authorJens Axboe <axboe@kernel.dk>
Wed, 19 Aug 2020 18:10:26 +0000 (12:10 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 19 Aug 2020 18:10:26 +0000 (12:10 -0600)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
init.c

diff --git a/init.c b/init.c
index 6ff7c68d72de1329ceb2ab8e84709dcd3519f1e2..3073c2a0f52caeb79197a56f8e1e506e0c864dcd 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1736,9 +1736,17 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
                        if (td_new->files) {
                                struct fio_file *f;
                                for_each_file(td_new, f, i) {
-                                       if (f->file_name)
-                                               sfree(f->file_name);
-                                       sfree(f);
+                                       bool use_smalloc = fio_file_smalloc(f);
+                                       if (f->file_name) {
+                                               if (use_smalloc)
+                                                       sfree(f->file_name);
+                                               else
+                                                       free(f->file_name);
+                                       }
+                                       if (use_smalloc)
+                                               sfree(f);
+                                       else
+                                               free(f);
                                }
                                free(td_new->files);
                                td_new->files = NULL;