aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r--tools/perf/util/util.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 95aefa78bb07..e52e7461911b 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -1,5 +1,6 @@
1#include "../perf.h" 1#include "../perf.h"
2#include "util.h" 2#include "util.h"
3#include "debug.h"
3#include <api/fs/fs.h> 4#include <api/fs/fs.h>
4#include <sys/mman.h> 5#include <sys/mman.h>
5#ifdef HAVE_BACKTRACE_SUPPORT 6#ifdef HAVE_BACKTRACE_SUPPORT
@@ -333,12 +334,9 @@ const char *find_tracing_dir(void)
333 if (!debugfs) 334 if (!debugfs)
334 return NULL; 335 return NULL;
335 336
336 tracing = malloc(strlen(debugfs) + 9); 337 if (asprintf(&tracing, "%s/tracing", debugfs) < 0)
337 if (!tracing)
338 return NULL; 338 return NULL;
339 339
340 sprintf(tracing, "%s/tracing", debugfs);
341
342 tracing_found = 1; 340 tracing_found = 1;
343 return tracing; 341 return tracing;
344} 342}
@@ -352,11 +350,9 @@ char *get_tracing_file(const char *name)
352 if (!tracing) 350 if (!tracing)
353 return NULL; 351 return NULL;
354 352
355 file = malloc(strlen(tracing) + strlen(name) + 2); 353 if (asprintf(&file, "%s/%s", tracing, name) < 0)
356 if (!file)
357 return NULL; 354 return NULL;
358 355
359 sprintf(file, "%s/%s", tracing, name);
360 return file; 356 return file;
361} 357}
362 358