aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/header.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r--tools/perf/util/header.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 16a16021eaa6..4b8c8397a947 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -270,15 +270,16 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
270 const char *name, bool is_kallsyms) 270 const char *name, bool is_kallsyms)
271{ 271{
272 const size_t size = PATH_MAX; 272 const size_t size = PATH_MAX;
273 char *filename = malloc(size), 273 char *realname = realpath(name, NULL),
274 *filename = malloc(size),
274 *linkname = malloc(size), *targetname; 275 *linkname = malloc(size), *targetname;
275 int len, err = -1; 276 int len, err = -1;
276 277
277 if (filename == NULL || linkname == NULL) 278 if (realname == NULL || filename == NULL || linkname == NULL)
278 goto out_free; 279 goto out_free;
279 280
280 len = snprintf(filename, size, "%s%s%s", 281 len = snprintf(filename, size, "%s%s%s",
281 debugdir, is_kallsyms ? "/" : "", name); 282 debugdir, is_kallsyms ? "/" : "", realname);
282 if (mkdir_p(filename, 0755)) 283 if (mkdir_p(filename, 0755))
283 goto out_free; 284 goto out_free;
284 285
@@ -288,7 +289,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
288 if (is_kallsyms) { 289 if (is_kallsyms) {
289 if (copyfile("/proc/kallsyms", filename)) 290 if (copyfile("/proc/kallsyms", filename))
290 goto out_free; 291 goto out_free;
291 } else if (link(name, filename) && copyfile(name, filename)) 292 } else if (link(realname, filename) && copyfile(name, filename))
292 goto out_free; 293 goto out_free;
293 } 294 }
294 295
@@ -305,6 +306,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
305 if (symlink(targetname, linkname) == 0) 306 if (symlink(targetname, linkname) == 0)
306 err = 0; 307 err = 0;
307out_free: 308out_free:
309 free(realname);
308 free(filename); 310 free(filename);
309 free(linkname); 311 free(linkname);
310 return err; 312 return err;