From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Namhyung Kim <namhyung@kernel.org>,
Kan Liang <kan.liang@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 2/2] perf annotate-data: Ensure the number of type histograms
Date: Sat, 11 May 2024 12:43:04 -0300 [thread overview]
Message-ID: <Zj-SCPBJn673kgbr@x1> (raw)
In-Reply-To: <CAP-5=fUBQ=GdeQdB25GNtS_ijRxu42W+uz4p6kuykG-8iC1DdA@mail.gmail.com>
On Fri, May 10, 2024 at 02:27:36PM -0700, Ian Rogers wrote:
> On Fri, May 10, 2024 at 2:04 PM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > Arnaldo reported that there is a case where nr_histograms and histograms
> > don't agree each other. It ended up in a segfault trying to access NULL
> > histograms array. Let's make sure to update the nr_histograms when the
> > histograms array is changed.
> >
> > Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>
> Reviewed-by: Ian Rogers <irogers@google.com>
Thanks, applied to perf-tools-next,
- Arnaldo
> Thanks,
> Ian
>
> > ---
> > tools/perf/util/annotate-data.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
> > index 57e7d4b3550b..965da6c0b542 100644
> > --- a/tools/perf/util/annotate-data.c
> > +++ b/tools/perf/util/annotate-data.c
> > @@ -1800,7 +1800,6 @@ static int alloc_data_type_histograms(struct annotated_data_type *adt, int nr_en
> > sz += sizeof(struct type_hist_entry) * adt->self.size;
> >
> > /* Allocate a table of pointers for each event */
> > - adt->nr_histograms = nr_entries;
> > adt->histograms = calloc(nr_entries, sizeof(*adt->histograms));
> > if (adt->histograms == NULL)
> > return -ENOMEM;
> > @@ -1814,6 +1813,8 @@ static int alloc_data_type_histograms(struct annotated_data_type *adt, int nr_en
> > if (adt->histograms[i] == NULL)
> > goto err;
> > }
> > +
> > + adt->nr_histograms = nr_entries;
> > return 0;
> >
> > err:
> > @@ -1827,7 +1828,9 @@ static void delete_data_type_histograms(struct annotated_data_type *adt)
> > {
> > for (int i = 0; i < adt->nr_histograms; i++)
> > zfree(&(adt->histograms[i]));
> > +
> > zfree(&adt->histograms);
> > + adt->nr_histograms = 0;
> > }
> >
> > void annotated_data_type__tree_delete(struct rb_root *root)
> > --
> > 2.45.0.118.g7fe29c98d7-goog
> >
next prev parent reply other threads:[~2024-05-11 15:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-10 14:40 perf annotate --data-type segfault Arnaldo Carvalho de Melo
2024-05-10 20:56 ` Namhyung Kim
2024-05-10 21:04 ` [PATCH 1/2] perf annotate: Fix segfault on sample histogram Namhyung Kim
2024-05-10 21:04 ` [PATCH 2/2] perf annotate-data: Ensure the number of type histograms Namhyung Kim
2024-05-10 21:27 ` Ian Rogers
2024-05-11 15:43 ` Arnaldo Carvalho de Melo [this message]
2024-05-10 21:27 ` [PATCH 1/2] perf annotate: Fix segfault on sample histogram Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zj-SCPBJn673kgbr@x1 \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.