Messages in this thread | | | Date | Wed, 12 Sep 2012 09:30:19 +0800 | From | "Yan, Zheng" <> | Subject | Re: [RFC PATCH 3/3] perf tool: Allow wildcard in PMU name |
| |
On 09/11/2012 10:05 PM, Jiri Olsa wrote: > On Mon, Sep 10, 2012 at 03:53:51PM +0800, Yan, Zheng wrote: >> From: "Yan, Zheng" <zheng.z.yan@intel.com> >> > > SNIP > >> +int parse_events_add_pmu(struct list_head **_list, int *idx, >> char *name, struct list_head *head_config) >> { >> struct perf_event_attr attr; >> - struct perf_pmu *pmu; >> + struct list_head *list; >> + struct perf_pmu *pmu = NULL; >> + struct perf_evsel *evsel, *first = NULL; >> + int orig_idx = *idx; >> >> - pmu = perf_pmu__find(name); >> - if (!pmu) >> - return -EINVAL; >> + list = malloc(sizeof(*list)); >> + if (!list) >> + return -ENOMEM; >> + INIT_LIST_HEAD(list); > > list should be allocated only if (!*_list)) same as in add_event function > > I haven't test, but I think you'll leak/loose events if there's another pmu > event defined after ',' >
I think *_list is always NULL, because the code in parse-event.y is:
--- PE_NAME '/' event_config '/' { struct parse_events_data__events *data = _data; struct list_head *list = NULL;
ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3)); parse_events__free_terms($3); $$ = list; }
---
Regards Yan, Zheng
| |