mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
perf expr: Initialize is_test value in expr__ctx_new()
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: 3340a08354 ("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>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
9ba3462c1c
commit
1d18ebcfd3
@@ -285,7 +285,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;
|
||||
|
||||
@@ -294,9 +294,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user