evsel_env() cannot return NULL. In case evsel->evlist->env is NULL default
to perf_env. Fixes crashes in evsel__open_strerror()
Signed-off-by: Ravi Bangoria <[email protected]>
Reviewed-by: Stephane Eranian <[email protected]>
---
tools/perf/util/evsel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 22d3267ce294..14b0e7ffa2c7 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2965,7 +2965,7 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
struct perf_env *evsel__env(struct evsel *evsel)
{
- if (evsel && evsel->evlist)
+ if (evsel && evsel->evlist && evsel->evlist->env)
return evsel->evlist->env;
return &perf_env;
}
--
2.35.1.894.gb6a874cedc-goog
On 3/22/22 5:15 PM, Stephane Eranian wrote:
> evsel_env() cannot return NULL. In case evsel->evlist->env is NULL default
> to perf_env. Fixes crashes in evsel__open_strerror()
>
> Signed-off-by: Ravi Bangoria <[email protected]>
> Reviewed-by: Stephane Eranian <[email protected]>
> ---
Signed-off-by: Kim Phillips <[email protected]>
FWIW, here's a link to one of the original submissions:
https://lkml.org/lkml/2022/1/26/1220
Thanks,
Kim
Em Tue, Mar 22, 2022 at 03:15:14PM -0700, Stephane Eranian escreveu:
> evsel_env() cannot return NULL. In case evsel->evlist->env is NULL default
> to perf_env. Fixes crashes in evsel__open_strerror()
>
> Signed-off-by: Ravi Bangoria <[email protected]>
> Reviewed-by: Stephane Eranian <[email protected]>
I have this already in from a patch by Kim Phillips.
- Arnaldo
> ---
> tools/perf/util/evsel.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 22d3267ce294..14b0e7ffa2c7 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -2965,7 +2965,7 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
>
> struct perf_env *evsel__env(struct evsel *evsel)
> {
> - if (evsel && evsel->evlist)
> + if (evsel && evsel->evlist && evsel->evlist->env)
> return evsel->evlist->env;
> return &perf_env;
> }
> --
> 2.35.1.894.gb6a874cedc-goog
--
- Arnaldo
On Fri, Mar 25, 2022 at 11:27 AM Arnaldo Carvalho de Melo
<[email protected]> wrote:
>
> Em Tue, Mar 22, 2022 at 03:15:14PM -0700, Stephane Eranian escreveu:
> > evsel_env() cannot return NULL. In case evsel->evlist->env is NULL default
> > to perf_env. Fixes crashes in evsel__open_strerror()
> >
> > Signed-off-by: Ravi Bangoria <[email protected]>
> > Reviewed-by: Stephane Eranian <[email protected]>
>
> I have this already in from a patch by Kim Phillips.
>
Ok, then. We are all set.
> - Arnaldo
>
> > ---
> > tools/perf/util/evsel.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> > index 22d3267ce294..14b0e7ffa2c7 100644
> > --- a/tools/perf/util/evsel.c
> > +++ b/tools/perf/util/evsel.c
> > @@ -2965,7 +2965,7 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
> >
> > struct perf_env *evsel__env(struct evsel *evsel)
> > {
> > - if (evsel && evsel->evlist)
> > + if (evsel && evsel->evlist && evsel->evlist->env)
> > return evsel->evlist->env;
> > return &perf_env;
> > }
> > --
> > 2.35.1.894.gb6a874cedc-goog
>
> --
>
> - Arnaldo