Skip to content

Commit

Permalink
Merge tag 'perf-urgent-2020-11-08' of git://git.kernel.org/pub/scm/li…
Browse files Browse the repository at this point in the history
…nux/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()
  • Loading branch information
torvalds committed Nov 8, 2020
2 parents aaaaa7e + 7bdb157 commit 100e389
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 ||
Expand All @@ -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);

Expand Down

0 comments on commit 100e389

Please sign in to comment.