From 2ba46d1b1a114688ff7be9852ba32d27c6e50188 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 11 Jan 2020 16:07:39 -0800 Subject: [PATCH] blktrace: Fix memory leaks in error paths This patch fixes the following Coverity complaint: CID 183977 (#1 of 1): Resource leak (RESOURCE_LEAK) 17. leaked_storage: Variable str going out of scope leaks the storage it points to. Signed-off-by: Bart Van Assche --- blktrace.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/blktrace.c b/blktrace.c index 2c2b5aeb..64a610a9 100644 --- a/blktrace.c +++ b/blktrace.c @@ -733,6 +733,7 @@ int merge_blktrace_iologs(struct thread_data *td) if (bcs[i].fd < 0) { log_err("fio: could not open file: %s\n", name); ret = bcs[i].fd; + free(str); goto err_file; } bcs[i].fifo = fifo_alloc(TRACE_FIFO_SIZE); @@ -740,11 +741,13 @@ int merge_blktrace_iologs(struct thread_data *td) if (!is_blktrace(name, &bcs[i].swap)) { log_err("fio: file is not a blktrace: %s\n", name); + free(str); goto err_file; } ret = read_trace(td, &bcs[i]); if (ret < 0) { + free(str); goto err_file; } else if (!ret) { merge_finish_file(bcs, i, &nr_logs); -- 2.25.1