Fix: lttng-crash: DIR leak in delete_trace() on error
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 5 Sep 2015 17:53:31 +0000 (13:53 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 5 Sep 2015 17:53:31 +0000 (13:53 -0400)
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 <jeremie.galarneau@efficios.com>
src/bin/lttng-crash/lttng-crash.c

index c3a8b778925d1de9bed8d191b1eec1324f982d2b..4d186dd557fb995ecbfd3b29f8637d63110b59d2 100644 (file)
@@ -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))) {
This page took 0.02697 seconds and 4 git commands to generate.