From: Damien Le Moal Date: Fri, 8 May 2020 07:56:39 +0000 (+0900) Subject: iolog: Fix write_iolog_close() X-Git-Tag: fio-3.20~19 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=d087d28fc4ed967836f561884e4154d2c437a9d5 iolog: Fix write_iolog_close() If the init_iolog() call from backend.c thread_main() fails (e.g. wrong file path given), td->iolog_f is not set but write_iolog_close() is still called from thread_main() error processing. This causes a seg fault and unclean termination of fio. Fix this by changing write_iolog_close() to do nothing if td->iolog_f is NULL. Signed-off-by: Damien Le Moal Signed-off-by: Jens Axboe --- diff --git a/iolog.c b/iolog.c index 917a446c..4a79fc46 100644 --- a/iolog.c +++ b/iolog.c @@ -342,6 +342,9 @@ void trim_io_piece(const struct io_u *io_u) void write_iolog_close(struct thread_data *td) { + if (!td->iolog_f) + return; + fflush(td->iolog_f); fclose(td->iolog_f); free(td->iolog_buf);