]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
perf test sdt: Handle realpath() failure
authorArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 1 Jul 2017 14:21:59 +0000 (11:21 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 19 Jul 2017 02:14:14 +0000 (23:14 -0300)
It can return NULL, in which case we should bail out and remove the
directory created with mkdtemp(), which is stored in the "__tempdir"
variable, not in "tempdir".

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Fixes: 8e5dc848356e ("perf test: Add a test case for SDT event")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/sdt.c

index 5abe8cea54e6b6c041e992be576bf9ed3d86fd3b..d80171526f6febfef62b00519679053f56ed87b9 100644 (file)
@@ -83,6 +83,8 @@ int test__sdt_event(int subtests __maybe_unused)
        }
        /* Note that buildid_dir must be an absolute path */
        tempdir = realpath(__tempdir, NULL);
+       if (tempdir == NULL)
+               goto error_rmdir;
 
        /* At first, scan itself */
        set_buildid_dir(tempdir);
@@ -100,7 +102,7 @@ int test__sdt_event(int subtests __maybe_unused)
 
 error_rmdir:
        /* Cleanup temporary buildid dir */
-       rm_rf(tempdir);
+       rm_rf(__tempdir);
 error:
        free(tempdir);
        free(myself);