From 920a187eae9f63e109072acde16d009b01dc95c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Sat, 5 Sep 2015 13:53:31 -0400 Subject: [PATCH] Fix: lttng-crash: DIR leak in delete_trace() on error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Implement a single return point in delete_trace() which ensures that trace_dir is not leaked on error. Signed-off-by: Jérémie Galarneau --- src/bin/lttng-crash/lttng-crash.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng-crash/lttng-crash.c b/src/bin/lttng-crash/lttng-crash.c index c3a8b7789..4d186dd55 100644 --- a/src/bin/lttng-crash/lttng-crash.c +++ b/src/bin/lttng-crash/lttng-crash.c @@ -1062,12 +1062,14 @@ int delete_trace(const char *trace_path) trace_dir = opendir(trace_path); if (!trace_dir) { PERROR("Cannot open '%s' path", trace_path); - return -1; + ret = -errno; + goto end; } trace_dir_fd = dirfd(trace_dir); if (trace_dir_fd < 0) { PERROR("dirfd"); - return -1; + ret = -errno; + goto end; } while ((entry = readdir(trace_dir))) { -- 2.34.1