[GIT pull] perf/urgent for v5.10-rc3

From: Thomas Gleixner
Date: Sun Nov 08 2020 - 10:25:06 EST


Linus,

please pull the latest perf/urgent branch from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf-urgent-2020-11-08

up to: 7bdb157cdebb: perf/core: Fix a memory leak in perf_event_parse_addr_filter()


A single fix for the perf core plugging a memory leak in the address filter
parser.

Thanks,

tglx

------------------>
kiyin(尹亮) (1):
perf/core: Fix a memory leak in perf_event_parse_addr_filter()


kernel/events/core.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index da467e1dd49a..5a29ab09e72d 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10085,6 +10085,7 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
if (token == IF_SRC_FILE || token == IF_SRC_FILEADDR) {
int fpos = token == IF_SRC_FILE ? 2 : 1;

+ kfree(filename);
filename = match_strdup(&args[fpos]);
if (!filename) {
ret = -ENOMEM;
@@ -10131,16 +10132,13 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
*/
ret = -EOPNOTSUPP;
if (!event->ctx->task)
- goto fail_free_name;
+ goto fail;

/* look up the path and grab its inode */
ret = kern_path(filename, LOOKUP_FOLLOW,
&filter->path);
if (ret)
- goto fail_free_name;
-
- kfree(filename);
- filename = NULL;
+ goto fail;

ret = -EINVAL;
if (!filter->path.dentry ||
@@ -10160,13 +10158,13 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
if (state != IF_STATE_ACTION)
goto fail;

+ kfree(filename);
kfree(orig);

return 0;

-fail_free_name:
- kfree(filename);
fail:
+ kfree(filename);
free_filters_list(filters);
kfree(orig);