On Sat, Sep 05, 2020 at 11:19:12AM +0900, Namhyung Kim wrote:
> The metric_event_delete() missed to free expr->metric_events and it
> should free an expr when metric_refs allocation failed.
> 
> Cc: Kajol Jain <[email protected]>
> Cc: John Garry <[email protected]>
> Cc: Ian Rogers <[email protected]>
> Fixes: 4ea2896715e67 ("perf metric: Collect referenced metrics in struct 
> metric_expr")
> Signed-off-by: Namhyung Kim <[email protected]>

Acked-by: Jiri Olsa <[email protected]>

thanks,
jirka

> ---
>  tools/perf/util/metricgroup.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index af664d6218d6..b28c09447c10 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -85,6 +85,7 @@ static void metric_event_delete(struct rblist *rblist 
> __maybe_unused,
>  
>       list_for_each_entry_safe(expr, tmp, &me->head, nd) {
>               free(expr->metric_refs);
> +             free(expr->metric_events);
>               free(expr);
>       }
>  
> @@ -316,6 +317,7 @@ static int metricgroup__setup_events(struct list_head 
> *groups,
>                       if (!metric_refs) {
>                               ret = -ENOMEM;
>                               free(metric_events);
> +                             free(expr);
>                               break;
>                       }
>  
> -- 
> 2.28.0.526.ge36021eeef-goog
> 

Reply via email to