init: fix more cases of leaking pid_file
[fio.git] / init.c
diff --git a/init.c b/init.c
index 35fbdf15365b3661b4dea465b2ae978be096cb59..6324dceefeda87959b7b218328bf5111e72f72f9 100644 (file)
--- a/init.c
+++ b/init.c
@@ -364,7 +364,7 @@ static struct thread_data *get_new_job(int global, struct thread_data *parent,
 
        td->thread_number = thread_number;
 
-       if (!parent || !parent->o.group_reporting)
+       if (!parent->o.group_reporting)
                stat_number++;
 
        set_cmd_options(td);
@@ -1842,7 +1842,7 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                        if (!strncmp(opt, "name", 4) && td) {
                                ret = add_job(td, td->o.name ?: "fio", 0, 0, client_type);
                                if (ret)
-                                       return 0;
+                                       goto out_free;
                                td = NULL;
                        }
                        if (!td) {
@@ -1857,7 +1857,7 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
 
                                td = get_new_job(global, &def_thread, 1);
                                if (!td || ioengine_load(td))
-                                       return 0;
+                                       goto out_free;
                                fio_options_set_ioengine_opts(l_opts, td);
                        }
 
@@ -1879,7 +1879,7 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                        if (!ret && !strcmp(opt, "ioengine")) {
                                free_ioengine(td);
                                if (ioengine_load(td))
-                                       return 0;
+                                       goto out_free;
                                fio_options_set_ioengine_opts(l_opts, td);
                        }
                        break;
@@ -2005,6 +2005,10 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                optind++;
        }
 
+out_free:
+       if (pid_file)
+               free(pid_file);
+
        return ini_idx;
 }