Skip to content

Commit

Permalink
HID: bpf: reorder BPF registration
Browse files Browse the repository at this point in the history
Given that our initial BPF program is not using any kfuncs anymore,
we can reorder the initialization to first try to load it and then
register the kfuncs. This has the advantage of not exporting kfuncs
when HID-BPF is not working.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Benjamin Tissoires authored and Jiri Kosina committed Jan 18, 2023
1 parent bb2c0ae commit 0c2d572
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/hid/bpf/hid_bpf_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,16 @@ static int __init hid_bpf_init(void)
return 0;
}

err = register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &hid_bpf_kfunc_set);
err = hid_bpf_preload_skel();
if (err) {
pr_warn("error while setting HID BPF tracing kfuncs: %d", err);
pr_warn("error while preloading HID BPF dispatcher: %d", err);
return 0;
}

err = hid_bpf_preload_skel();
/* register tracing kfuncs after we are sure we can load our preloaded bpf program */
err = register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &hid_bpf_kfunc_set);
if (err) {
pr_warn("error while preloading HID BPF dispatcher: %d", err);
pr_warn("error while setting HID BPF tracing kfuncs: %d", err);
return 0;
}

Expand Down

0 comments on commit 0c2d572

Please sign in to comment.