lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 7 Jul 2013 19:00:48 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	David Ahern <dsahern@...il.com>
Cc:	acme@...stprotocols.net, linux-kernel@...r.kernel.org,
	Ingo Molnar <mingo@...nel.org>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Namhyung Kim <namhyung@...nel.org>,
	Adrian Hunter <adrian.hunter@...el.com>
Subject: Re: [PATCH 6/6] perf parse events: demystify memory allocations

On Sun, Jul 07, 2013 at 10:45:13AM -0600, David Ahern wrote:
> On 7/7/13 9:26 AM, Jiri Olsa wrote:
> >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?
> 
> According to valgrind that memory is not freed prior to this patch,
> so this one does not introduce new leaks.

I thought this hunk did:


        evsel = perf_evsel__new(attr, (*idx)++);
-       if (!evsel) {
-               free(list);


but I might have missed other cases..

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ