Skip to content

Commit 45210e1

Browse files
ahunter6acmel
authored andcommitted
perf dlfilter: Avoid leak in v0 API test use of resolve_address()
The introduction of reference counting causes the v0 API perf_dlfilter_fns.resolve_address() to leak. v2 API introduced perf_dlfilter_fns.al_cleanup() to prevent that. For the v0 API, avoid the leak by exiting the addr_location immediately, since the documentation makes it clear that pointers obtained via perf_dlfilter_fns are not necessarily valid (dereferenceable) after 'filter_event' and 'filter_event_early' return. Reported-by: kernel test robot <[email protected]> Signed-off-by: Adrian Hunter <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Closes: https://lore.kernel.org/oe-lkp/[email protected] Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent f0005f1 commit 45210e1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/perf/util/dlfilter.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ static __s32 dlfilter__resolve_address(void *ctx, __u64 address, struct perf_dlf
187187

188188
if (has_priv(d_al_p))
189189
d_al_p->priv = memdup(&al, sizeof(al));
190+
else /* Avoid leak for v0 API */
191+
addr_location__exit(&al);
190192

191193
return 0;
192194
}

0 commit comments

Comments
 (0)