Skip to content

Commit c673b7f

Browse files
namhyungacmel
authored andcommitted
perf stat: Fix error check for bpf_program__attach
It seems the bpf_program__attach() returns a negative error code instead of a NULL pointer in case of error. Fixes: 7fac83a ("perf stat: Introduce 'bperf' to share hardware PMCs with BPF") Signed-off-by: Namhyung Kim <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Song Liu <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent c59870e commit c673b7f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/perf/util/bpf_counter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,10 @@ static int bperf_reload_leader_program(struct evsel *evsel, int attr_map_fd,
451451
goto out;
452452
}
453453

454-
err = -1;
455454
link = bpf_program__attach(skel->progs.on_switch);
456-
if (!link) {
455+
if (IS_ERR(link)) {
457456
pr_err("Failed to attach leader program\n");
457+
err = PTR_ERR(link);
458458
goto out;
459459
}
460460

0 commit comments

Comments
 (0)