iolog.c: Fix memory leak for blkparse case
authorLukas Straub <lukasstraub2@web.de>
Wed, 19 Jan 2022 21:14:40 +0000 (21:14 +0000)
committerJens Axboe <axboe@kernel.dk>
Thu, 20 Jan 2022 18:40:42 +0000 (11:40 -0700)
init_blkparse_read (load_blkparse previously) didn't free the
filename. Fix this by freeing it in the init_iolog function and
handling it for both init_iolog_read and init_blkparse_read.

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
Link: https://lore.kernel.org/r/e4acf183ab789b7284bfa96089ebe1256e15f98d.1642626314.git.lukasstraub2@web.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
iolog.c

diff --git a/iolog.c b/iolog.c
index 5a41e93fa2644ab98e8a3cf5f24e308aaa05c5b1..a2cf0c1ccd6083ebf2b3c0d11686713238ad2983 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -631,8 +631,6 @@ static bool init_iolog_read(struct thread_data *td, char *fname)
        } else
                f = fopen(fname, "r");
 
        } else
                f = fopen(fname, "r");
 
-       free(fname);
-
        if (!f) {
                perror("fopen read iolog");
                return false;
        if (!f) {
                perror("fopen read iolog");
                return false;
@@ -719,6 +717,7 @@ bool init_iolog(struct thread_data *td)
                        td->io_log_blktrace = 0;
                        ret = init_iolog_read(td, fname);
                }
                        td->io_log_blktrace = 0;
                        ret = init_iolog_read(td, fname);
                }
+               free(fname);
        } else if (td->o.write_iolog_file)
                ret = init_iolog_write(td);
        else
        } else if (td->o.write_iolog_file)
                ret = init_iolog_write(td);
        else