* [PATCH 1/1] perf/util: initialize is_test value in expr__ctx_new()
@ 2024-11-08 14:34 Levi Yun
2024-11-13 16:13 ` James Clark
0 siblings, 1 reply; 4+ messages in thread
From: Levi Yun @ 2024-11-08 14:34 UTC (permalink / raw)
To: namhyung, mark.rutland, irogers, james.clark2
Cc: linux-perf-users, linux-kernel, nd, Levi Yun
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: 3340a08354ac ("perf pmu-events: Fix testing with JEVENTS_ARCH=all")
Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
---
tools/perf/util/expr.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
index 5e3732bc2fa5..bc119501f091 100644
--- a/tools/perf/util/expr.c
+++ b/tools/perf/util/expr.c
@@ -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;
}
--
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] perf/util: initialize is_test value in expr__ctx_new()
2024-11-08 14:34 [PATCH 1/1] perf/util: initialize is_test value in expr__ctx_new() Levi Yun
@ 2024-11-13 16:13 ` James Clark
2024-11-13 16:57 ` Ian Rogers
0 siblings, 1 reply; 4+ messages in thread
From: James Clark @ 2024-11-13 16:13 UTC (permalink / raw)
To: Levi Yun
Cc: linux-perf-users, linux-kernel, nd, namhyung, mark.rutland,
irogers, james.clark2
On 08/11/2024 2:34 pm, Levi Yun wrote:
> 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: 3340a08354ac ("perf pmu-events: Fix testing with JEVENTS_ARCH=all")
> Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
> ---
> tools/perf/util/expr.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
> index 5e3732bc2fa5..bc119501f091 100644
> --- a/tools/perf/util/expr.c
> +++ b/tools/perf/util/expr.c
> @@ -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;
> }
> --
> LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}
>
>
Reviewed-by: James Clark <james.clark@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] perf/util: initialize is_test value in expr__ctx_new()
2024-11-13 16:13 ` James Clark
@ 2024-11-13 16:57 ` Ian Rogers
2024-12-12 19:12 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 4+ messages in thread
From: Ian Rogers @ 2024-11-13 16:57 UTC (permalink / raw)
To: James Clark
Cc: Levi Yun, linux-perf-users, linux-kernel, nd, namhyung,
mark.rutland, james.clark2
On Wed, Nov 13, 2024 at 8:13 AM James Clark <james.clark@linaro.org> wrote:
>
>
>
> On 08/11/2024 2:34 pm, Levi Yun wrote:
> > 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: 3340a08354ac ("perf pmu-events: Fix testing with JEVENTS_ARCH=all")
> > Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
> > ---
> > tools/perf/util/expr.c | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
> > index 5e3732bc2fa5..bc119501f091 100644
> > --- a/tools/perf/util/expr.c
> > +++ b/tools/perf/util/expr.c
> > @@ -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;
> > }
> > --
> > LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}
> >
> >
>
> Reviewed-by: James Clark <james.clark@linaro.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] perf/util: initialize is_test value in expr__ctx_new()
2024-11-13 16:57 ` Ian Rogers
@ 2024-12-12 19:12 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-12-12 19:12 UTC (permalink / raw)
To: Ian Rogers
Cc: James Clark, Levi Yun, linux-perf-users, linux-kernel, nd,
namhyung, mark.rutland, james.clark2
On Wed, Nov 13, 2024 at 08:57:08AM -0800, Ian Rogers wrote:
> On Wed, Nov 13, 2024 at 8:13 AM James Clark <james.clark@linaro.org> wrote:
> > On 08/11/2024 2:34 pm, Levi Yun wrote:
> > > 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: 3340a08354ac ("perf pmu-events: Fix testing with JEVENTS_ARCH=all")
> > > Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
> > > ---
> > > tools/perf/util/expr.c | 5 +----
> > > 1 file changed, 1 insertion(+), 4 deletions(-)
> > >
> > > diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
> > > index 5e3732bc2fa5..bc119501f091 100644
> > > --- a/tools/perf/util/expr.c
> > > +++ b/tools/perf/util/expr.c
> > > @@ -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;
> > > }
> > > --
> > > LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}
> > >
> > >
> >
> > Reviewed-by: James Clark <james.clark@linaro.org>
>
> Reviewed-by: Ian Rogers <irogers@google.com>
Thanks, applied to perf-tools-next,
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-12 19:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-08 14:34 [PATCH 1/1] perf/util: initialize is_test value in expr__ctx_new() Levi Yun
2024-11-13 16:13 ` James Clark
2024-11-13 16:57 ` Ian Rogers
2024-12-12 19:12 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).