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>
此提交包含在:
Arnaldo Carvalho de Melo
2019-07-04 12:06:20 -03:00
父節點 7f7c536f23
當前提交 d8f9da2404
共有 33 個檔案被更改,包括 100 行新增99 行删除

查看文件

@@ -1586,7 +1586,7 @@ static void runtime_stat_delete(struct perf_stat_config *config)
for (i = 0; i < config->stats_num; i++)
runtime_stat__exit(&config->stats[i]);
free(config->stats);
zfree(&config->stats);
}
static const char * const stat_report_usage[] = {
@@ -2003,7 +2003,7 @@ int cmd_stat(int argc, const char **argv)
perf_stat__exit_aggr_mode();
perf_evlist__free_stats(evsel_list);
out:
free(stat_config.walltime_run);
zfree(&stat_config.walltime_run);
if (smi_cost && smi_reset)
sysfs__write_int(FREEZE_ON_SMI_PATH, 0);