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.7.0-rc2~71 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=4728260132472cdda0fac8c87c7546cbe821b18e;p=lttng-tools.git 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))) {