Commit d2d09fbe authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'perf-tools-fixes-for-v5.12-2021-04-25' of...

Merge tag 'perf-tools-fixes-for-v5.12-2021-04-25' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

Pull perf tools fixes from Arnaldo Carvalho de Melo:

 - Fix potential NULL pointer dereference in the auxtrace option parser

 - Fix access to PID in an array when setting a PID filter in 'perf ftrace'

 - Fix error return code in the 'perf data' tool and in maps__clone(),
   found using a static analysis tool from Huawei

* tag 'perf-tools-fixes-for-v5.12-2021-04-25' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
  perf map: Fix error return code in maps__clone()
  perf ftrace: Fix access to pid in array when setting a pid filter
  perf auxtrace: Fix potential NULL pointer dereference
  perf data: Fix error return code in perf_data__create_dir()
parents 24dfc390 c6f87141
...@@ -289,7 +289,7 @@ static int set_tracing_pid(struct perf_ftrace *ftrace) ...@@ -289,7 +289,7 @@ static int set_tracing_pid(struct perf_ftrace *ftrace)
for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) { for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) {
scnprintf(buf, sizeof(buf), "%d", scnprintf(buf, sizeof(buf), "%d",
ftrace->evlist->core.threads->map[i]); perf_thread_map__pid(ftrace->evlist->core.threads, i));
if (append_tracing_file("set_ftrace_pid", buf) < 0) if (append_tracing_file("set_ftrace_pid", buf) < 0)
return -1; return -1;
} }
......
...@@ -634,7 +634,7 @@ int auxtrace_parse_snapshot_options(struct auxtrace_record *itr, ...@@ -634,7 +634,7 @@ int auxtrace_parse_snapshot_options(struct auxtrace_record *itr,
break; break;
} }
if (itr) if (itr && itr->parse_snapshot_options)
return itr->parse_snapshot_options(itr, opts, str); return itr->parse_snapshot_options(itr, opts, str);
pr_err("No AUX area tracing to snapshot\n"); pr_err("No AUX area tracing to snapshot\n");
......
...@@ -35,7 +35,7 @@ void perf_data__close_dir(struct perf_data *data) ...@@ -35,7 +35,7 @@ void perf_data__close_dir(struct perf_data *data)
int perf_data__create_dir(struct perf_data *data, int nr) int perf_data__create_dir(struct perf_data *data, int nr)
{ {
struct perf_data_file *files = NULL; struct perf_data_file *files = NULL;
int i, ret = -1; int i, ret;
if (WARN_ON(!data->is_dir)) if (WARN_ON(!data->is_dir))
return -EINVAL; return -EINVAL;
...@@ -51,7 +51,8 @@ int perf_data__create_dir(struct perf_data *data, int nr) ...@@ -51,7 +51,8 @@ int perf_data__create_dir(struct perf_data *data, int nr)
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
struct perf_data_file *file = &files[i]; struct perf_data_file *file = &files[i];
if (asprintf(&file->path, "%s/data.%d", data->path, i) < 0) ret = asprintf(&file->path, "%s/data.%d", data->path, i);
if (ret < 0)
goto out_err; goto out_err;
ret = open(file->path, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR); ret = open(file->path, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);
......
...@@ -840,15 +840,18 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) ...@@ -840,15 +840,18 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
int maps__clone(struct thread *thread, struct maps *parent) int maps__clone(struct thread *thread, struct maps *parent)
{ {
struct maps *maps = thread->maps; struct maps *maps = thread->maps;
int err = -ENOMEM; int err;
struct map *map; struct map *map;
down_read(&parent->lock); down_read(&parent->lock);
maps__for_each_entry(parent, map) { maps__for_each_entry(parent, map) {
struct map *new = map__clone(map); struct map *new = map__clone(map);
if (new == NULL)
if (new == NULL) {
err = -ENOMEM;
goto out_unlock; goto out_unlock;
}
err = unwind__prepare_access(maps, new, NULL); err = unwind__prepare_access(maps, new, NULL);
if (err) if (err)
......
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