lkml.org 
[lkml]   [2020]   [Sep]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/4] perf tools: Copy metric events properly when expand cgroups
On Wed, Sep 16, 2020 at 03:31:28PM +0900, Namhyung Kim wrote:

SNIP

> + free(new_expr);
> + return -ENOMEM;
> + }
> +
> + memcpy(new_expr->metric_refs, old_expr->metric_refs,
> + nr * alloc_size);
> + } else {
> + new_expr->metric_refs = NULL;
> + }
> +
> + /* calculate number of metric_events */
> + for (nr = 0; old_expr->metric_events[nr]; nr++)
> + continue;
> + alloc_size = sizeof(*new_expr->metric_events);
> + new_expr->metric_events = calloc(nr + 1, alloc_size);
> + if (!new_expr->metric_events) {
> + free(new_expr->metric_refs);
> + free(new_expr);
> + return -ENOMEM;
> + }
> +
> + /* copy evsel in the same position */
> + for (idx = 0; idx < nr; idx++) {
> + evsel = old_expr->metric_events[idx];
> + evsel = evlist__get_evsel(evlist, evsel->idx);

this probably won't happen, but evlist__get_evsel can return NULL

jirka

> + new_expr->metric_events[idx] = evsel;
> + }
> +
> + list_add(&new_expr->nd, &new_me->head);
> + }
> + }
> + return 0;
> +}

SNIP

\
 
 \ /
  Last update: 2020-09-18 15:46    [W:0.096 / U:8.864 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site