From: Bart Van Assche Date: Sun, 12 Jan 2020 00:07:39 +0000 (-0800) Subject: blktrace: Fix memory leaks in error paths X-Git-Tag: fio-3.18~12^2~4 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=2ba46d1b1a114688ff7be9852ba32d27c6e50188;p=fio.git 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 --- 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);