Skip to content

Commit 0c2d572

Browse files
bentissJiri Kosina
authored andcommitted
HID: bpf: reorder BPF registration
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 <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent bb2c0ae commit 0c2d572

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/hid/bpf/hid_bpf_dispatch.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,15 +514,16 @@ static int __init hid_bpf_init(void)
514514
return 0;
515515
}
516516

517-
err = register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &hid_bpf_kfunc_set);
517+
err = hid_bpf_preload_skel();
518518
if (err) {
519-
pr_warn("error while setting HID BPF tracing kfuncs: %d", err);
519+
pr_warn("error while preloading HID BPF dispatcher: %d", err);
520520
return 0;
521521
}
522522

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

0 commit comments

Comments
 (0)