summaryrefslogtreecommitdiff
path: root/tools/perf/util/tool_pmu.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/tool_pmu.c')
-rw-r--r--tools/perf/util/tool_pmu.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/perf/util/tool_pmu.c b/tools/perf/util/tool_pmu.c
index 9156745ea180..d43d6cf6e4a2 100644
--- a/tools/perf/util/tool_pmu.c
+++ b/tools/perf/util/tool_pmu.c
@@ -494,12 +494,20 @@ struct perf_pmu *tool_pmu__new(void)
{
struct perf_pmu *tool = zalloc(sizeof(struct perf_pmu));
+ if (!tool)
+ goto out;
tool->name = strdup("tool");
+ if (!tool->name) {
+ zfree(&tool);
+ goto out;
+ }
+
tool->type = PERF_PMU_TYPE_TOOL;
INIT_LIST_HEAD(&tool->aliases);
INIT_LIST_HEAD(&tool->caps);
INIT_LIST_HEAD(&tool->format);
tool->events_table = find_core_events_table("common", "common");
+out:
return tool;
}