diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-07-04 12:06:20 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-07-09 10:13:27 -0300 |
commit | d8f9da240495b50766239410f9b0c715ca506a67 (patch) | |
tree | a9fb3abcc48a72cd34a9299f081aab497325711f /tools/perf/ui/browsers/res_sample.c | |
parent | 7f7c536f23e6afaa5d5d4b0e0958b0be8922491f (diff) | |
download | linux-next-d8f9da240495b50766239410f9b0c715ca506a67.tar.gz |
perf tools: Use zfree() where applicable
In places where the equivalent was already being done, i.e.:
free(a);
a = NULL;
And in placs where struct members are being freed so that if we have
some erroneous reference to its struct, then accesses to freed members
will result in segfaults, which we can detect faster than use after free
to areas that may still have something seemingly valid.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-jatyoofo5boc1bsvoig6bb6i@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui/browsers/res_sample.c')
-rw-r--r-- | tools/perf/ui/browsers/res_sample.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/perf/ui/browsers/res_sample.c b/tools/perf/ui/browsers/res_sample.c index c0dd73176d42..8aa3547bb9ff 100644 --- a/tools/perf/ui/browsers/res_sample.c +++ b/tools/perf/ui/browsers/res_sample.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 /* Display a menu with individual samples to browse with perf script */ -#include "util.h" #include "hist.h" #include "evsel.h" #include "hists.h" @@ -8,6 +7,7 @@ #include "config.h" #include "time-utils.h" #include <linux/time64.h> +#include <linux/zalloc.h> static u64 context_len = 10 * NSEC_PER_MSEC; @@ -46,14 +46,14 @@ int res_sample_browse(struct res_sample *res_samples, int num_res, if (asprintf(&names[i], "%s: CPU %d tid %d", tbuf, res_samples[i].cpu, res_samples[i].tid) < 0) { while (--i >= 0) - free(names[i]); + zfree(&names[i]); free(names); return -1; } } choice = ui__popup_menu(num_res, names); for (i = 0; i < num_res; i++) - free(names[i]); + zfree(&names[i]); free(names); if (choice < 0 || choice >= num_res) |