lkml.org 
[lkml]   [2013]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 6/6] perf parse events: demystify memory allocations
On Tue, Jul 02, 2013 at 01:27:25PM -0600, David Ahern wrote:
> List heads are currently allocated way down the function chain in __add_event
> and add_tracepoint and then freed when the scanner code calls
> parse_events_update_lists.
>
> Be more explicit with where memory is allocated and who should free it. With
> this patch the list_head is allocated in the scanner code and freed when the
> scanner code calls parse_events_update_lists.
>

SNIP

> @@ -266,9 +279,10 @@ event_legacy_mem:
> PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
> {
> struct parse_events_evlist *data = _data;
> - struct list_head *list = NULL;
> + struct list_head *list;
>
> - ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
> + ALLOC_LIST(list);
> + ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
> (void *) $2, $4));
> $$ = list;
> }
> @@ -276,9 +290,10 @@ PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
> PE_PREFIX_MEM PE_VALUE sep_dc
> {
> struct parse_events_evlist *data = _data;
> - struct list_head *list = NULL;
> + struct list_head *list;
>
> - ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
> + ALLOC_LIST(list);
> + ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
> (void *) $2, NULL));

so who now frees the list if there's an error
in parse_events_add_breakpoint?

ditto for other ABORT_ON cases

jirka


\
 
 \ /
  Last update: 2013-07-07 18:01    [W:8.915 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site