[tip:perf/core] perf test sdt: Handle realpath() failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  8526bafc149ee4d0df5eabca0f440164ec705c99
Gitweb:     http://git.kernel.org/tip/8526bafc149ee4d0df5eabca0f440164ec705c99
Author:     Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
AuthorDate: Sat, 1 Jul 2017 11:21:59 -0300
Committer:  Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
CommitDate: Tue, 18 Jul 2017 23:14:14 -0300

perf test sdt: Handle realpath() failure

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@xxxxxxxxxx>
Fixes: 8e5dc848356e ("perf test: Add a test case for SDT event")
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
 tools/perf/tests/sdt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c
index 5abe8ce..d801715 100644
--- a/tools/perf/tests/sdt.c
+++ b/tools/perf/tests/sdt.c
@@ -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);
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux