init: fix more cases of leaking pid_file
authorJens Axboe <axboe@fb.com>
Mon, 14 Apr 2014 14:17:30 +0000 (08:17 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 14 Apr 2014 14:17:30 +0000 (08:17 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
init.c

diff --git a/init.c b/init.c
index 215b60d40418c9e379cfc50b3e93493ebf3656e6..6324dceefeda87959b7b218328bf5111e72f72f9 100644 (file)
--- a/init.c
+++ b/init.c
@@ -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;
 }