Commit 100e3891 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull perf fix from Thomas Gleixner:
 "A single fix for the perf core plugging a memory leak in the address
  filter parser"

* tag 'perf-urgent-2020-11-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf/core: Fix a memory leak in perf_event_parse_addr_filter()
parents aaaaa7ec 7bdb157c
...@@ -10085,6 +10085,7 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr, ...@@ -10085,6 +10085,7 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
if (token == IF_SRC_FILE || token == IF_SRC_FILEADDR) { if (token == IF_SRC_FILE || token == IF_SRC_FILEADDR) {
int fpos = token == IF_SRC_FILE ? 2 : 1; int fpos = token == IF_SRC_FILE ? 2 : 1;
kfree(filename);
filename = match_strdup(&args[fpos]); filename = match_strdup(&args[fpos]);
if (!filename) { if (!filename) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -10131,16 +10132,13 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr, ...@@ -10131,16 +10132,13 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
*/ */
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
if (!event->ctx->task) if (!event->ctx->task)
goto fail_free_name; goto fail;
/* look up the path and grab its inode */ /* look up the path and grab its inode */
ret = kern_path(filename, LOOKUP_FOLLOW, ret = kern_path(filename, LOOKUP_FOLLOW,
&filter->path); &filter->path);
if (ret) if (ret)
goto fail_free_name; goto fail;
kfree(filename);
filename = NULL;
ret = -EINVAL; ret = -EINVAL;
if (!filter->path.dentry || if (!filter->path.dentry ||
...@@ -10160,13 +10158,13 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr, ...@@ -10160,13 +10158,13 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
if (state != IF_STATE_ACTION) if (state != IF_STATE_ACTION)
goto fail; goto fail;
kfree(filename);
kfree(orig); kfree(orig);
return 0; return 0;
fail_free_name:
kfree(filename);
fail: fail:
kfree(filename);
free_filters_list(filters); free_filters_list(filters);
kfree(orig); kfree(orig);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment