Skip to content

Commit 6cb22ed

Browse files
mhiramatgregkh
authored andcommitted
perf probe: Fix memory leakage when the probe point is not found
[ Upstream commit 12d572e ] Fix the memory leakage in debuginfo__find_trace_events() when the probe point is not found in the debuginfo. If there is no probe point found in the debuginfo, debuginfo__find_probes() will NOT return -ENOENT, but 0. Thus the caller of debuginfo__find_probes() must check the tf.ntevs and release the allocated memory for the array of struct probe_trace_event. The current code releases the memory only if the debuginfo__find_probes() hits an error but not checks tf.ntevs. In the result, the memory allocated on *tevs are not released if tf.ntevs == 0. This fixes the memory leakage by checking tf.ntevs == 0 in addition to ret < 0. Fixes: ff74178 ("perf probe: Introduce debuginfo to encapsulate dwarf information") Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Reviewed-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: stable@vger.kernel.org Link: http://lore.kernel.org/lkml/159438668346.62703.10887420400718492503.stgit@devnote2 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b93a387 commit 6cb22ed

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tools/perf/util/probe-finder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ int debuginfo__find_trace_events(struct debuginfo *dbg,
13511351
tf.ntevs = 0;
13521352

13531353
ret = debuginfo__find_probes(dbg, &tf.pf);
1354-
if (ret < 0) {
1354+
if (ret < 0 || tf.ntevs == 0) {
13551355
for (i = 0; i < tf.ntevs; i++)
13561356
clear_probe_trace_event(&tf.tevs[i]);
13571357
zfree(tevs);

0 commit comments

Comments
 (0)