summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLevi Yun <yeoreum.yun@arm.com>2024-11-08 14:34:25 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-08 09:57:29 +0100
commit58ad9c26238f0e9e2a438e70f2cd2a8eaf184f63 (patch)
treebdd1dea3b36039915caf43dc5641e7a6b14ba9a2 /tools
parent2ac66e67678ad05e9278fb823658de1c77593d75 (diff)
downloadlinux-58ad9c26238f0e9e2a438e70f2cd2a8eaf184f63.tar.gz
linux-58ad9c26238f0e9e2a438e70f2cd2a8eaf184f63.tar.bz2
linux-58ad9c26238f0e9e2a438e70f2cd2a8eaf184f63.zip
perf expr: Initialize is_test value in expr__ctx_new()
[ Upstream commit 1d18ebcfd302a2005b83ae5f13df223894d19902 ] When expr_parse_ctx is allocated by expr_ctx_new(), expr_scanner_ctx->is_test isn't initialize, so it has garbage value. this can affects the result of expr__parse() return when it parses non-exist event literal according to garbage value. Use calloc instead of malloc in expr_ctx_new() to fix this. Fixes: 3340a08354ac286e ("perf pmu-events: Fix testing with JEVENTS_ARCH=all") Reviewed-by: Ian Rogers <irogers@google.com> Reviewed-by: James Clark <james.clark@linaro.org> Signed-off-by: Levi Yun <yeoreum.yun@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20241108143424.819126-1-yeoreum.yun@arm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/expr.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
index b2536a59c44e..90c6ce2212e4 100644
--- a/tools/perf/util/expr.c
+++ b/tools/perf/util/expr.c
@@ -288,7 +288,7 @@ struct expr_parse_ctx *expr__ctx_new(void)
{
struct expr_parse_ctx *ctx;
- ctx = malloc(sizeof(struct expr_parse_ctx));
+ ctx = calloc(1, sizeof(struct expr_parse_ctx));
if (!ctx)
return NULL;
@@ -297,9 +297,6 @@ struct expr_parse_ctx *expr__ctx_new(void)
free(ctx);
return NULL;
}
- ctx->sctx.user_requested_cpu_list = NULL;
- ctx->sctx.runtime = 0;
- ctx->sctx.system_wide = false;
return ctx;
}