mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-21 22:32:45 +00:00
perf annotate: Split allocation of annotated_source struct
So that we can allocate just the notes->src->cyc_hist, that, unlike notes->src->histograms, is not per event, and in paths where we need to lazily allocate notes->src->cyc_hist we don't have the number of events handy to also allocate ->histograms. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-tsx7dhxzpi0criyx0sio3pz3@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
f40dd6d1b4
commit
116c626b9a
2 changed files with 10 additions and 6 deletions
|
@ -701,13 +701,17 @@ int symbol__alloc_hist(struct symbol *sym)
|
|||
sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(struct sym_hist_entry));
|
||||
|
||||
/* Check for overflow in zalloc argument */
|
||||
if (sizeof_sym_hist > (SIZE_MAX - sizeof(*notes->src))
|
||||
/ symbol_conf.nr_events)
|
||||
if (sizeof_sym_hist > SIZE_MAX / symbol_conf.nr_events)
|
||||
return -1;
|
||||
|
||||
notes->src = zalloc(sizeof(*notes->src) + symbol_conf.nr_events * sizeof_sym_hist);
|
||||
notes->src = zalloc(sizeof(*notes->src));
|
||||
if (notes->src == NULL)
|
||||
return -1;
|
||||
notes->src->histograms = calloc(symbol_conf.nr_events, sizeof_sym_hist);
|
||||
if (notes->src->histograms == NULL) {
|
||||
zfree(¬es->src);
|
||||
return -1;
|
||||
}
|
||||
notes->src->sizeof_sym_hist = sizeof_sym_hist;
|
||||
notes->src->nr_histograms = symbol_conf.nr_events;
|
||||
INIT_LIST_HEAD(¬es->src->source);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue