Skip to content

Commit d2d09fb

Browse files
committed
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()
2 parents 24dfc39 + c6f8714 commit d2d09fb

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

tools/perf/builtin-ftrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static int set_tracing_pid(struct perf_ftrace *ftrace)
289289

290290
for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) {
291291
scnprintf(buf, sizeof(buf), "%d",
292-
ftrace->evlist->core.threads->map[i]);
292+
perf_thread_map__pid(ftrace->evlist->core.threads, i));
293293
if (append_tracing_file("set_ftrace_pid", buf) < 0)
294294
return -1;
295295
}

tools/perf/util/auxtrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ int auxtrace_parse_snapshot_options(struct auxtrace_record *itr,
634634
break;
635635
}
636636

637-
if (itr)
637+
if (itr && itr->parse_snapshot_options)
638638
return itr->parse_snapshot_options(itr, opts, str);
639639

640640
pr_err("No AUX area tracing to snapshot\n");

tools/perf/util/data.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void perf_data__close_dir(struct perf_data *data)
3535
int perf_data__create_dir(struct perf_data *data, int nr)
3636
{
3737
struct perf_data_file *files = NULL;
38-
int i, ret = -1;
38+
int i, ret;
3939

4040
if (WARN_ON(!data->is_dir))
4141
return -EINVAL;
@@ -51,7 +51,8 @@ int perf_data__create_dir(struct perf_data *data, int nr)
5151
for (i = 0; i < nr; i++) {
5252
struct perf_data_file *file = &files[i];
5353

54-
if (asprintf(&file->path, "%s/data.%d", data->path, i) < 0)
54+
ret = asprintf(&file->path, "%s/data.%d", data->path, i);
55+
if (ret < 0)
5556
goto out_err;
5657

5758
ret = open(file->path, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);

tools/perf/util/map.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,15 +840,18 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
840840
int maps__clone(struct thread *thread, struct maps *parent)
841841
{
842842
struct maps *maps = thread->maps;
843-
int err = -ENOMEM;
843+
int err;
844844
struct map *map;
845845

846846
down_read(&parent->lock);
847847

848848
maps__for_each_entry(parent, map) {
849849
struct map *new = map__clone(map);
850-
if (new == NULL)
850+
851+
if (new == NULL) {
852+
err = -ENOMEM;
851853
goto out_unlock;
854+
}
852855

853856
err = unwind__prepare_access(maps, new, NULL);
854857
if (err)

0 commit comments

Comments
 (0)