From: Jérémie Galarneau Date: Sat, 5 Sep 2015 17:53:31 +0000 (-0400) Subject: Fix: lttng-crash: DIR leak in delete_trace() on error X-Git-Tag: v2.8.0-rc1~395 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=920a187eae9f63e109072acde16d009b01dc95c3 Fix: lttng-crash: DIR leak in delete_trace() on error 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 --- 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))) {