diff options
author | Benjamin Tissoires <benjamin.tissoires@redhat.com> | 2022-11-03 16:57:47 +0100 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2022-11-15 16:28:29 +0100 |
commit | 658ee5a64fcfbbf758447fa3af425729eaabb0dc (patch) | |
tree | 6ad106ac6621a5e840840e03c736db9858c3ffd4 /drivers/hid/bpf/hid_bpf_jmp_table.c | |
parent | 0baef37335dd4d5cffd00c9b8bbf2e0b71e4239f (diff) | |
download | linux-stable-658ee5a64fcfbbf758447fa3af425729eaabb0dc.tar.gz linux-stable-658ee5a64fcfbbf758447fa3af425729eaabb0dc.tar.bz2 linux-stable-658ee5a64fcfbbf758447fa3af425729eaabb0dc.zip |
HID: bpf: allocate data memory for device_event BPF programs
We need to also be able to change the size of the report.
Reducing it is easy, because we already have the incoming buffer that is
big enough, but extending it is harder.
Pre-allocate a buffer that is big enough to handle all reports of the
device, and use that as the primary buffer for BPF programs.
To be able to change the size of the buffer, we change the device_event
API and request it to return the size of the buffer.
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/bpf/hid_bpf_jmp_table.c')
-rw-r--r-- | drivers/hid/bpf/hid_bpf_jmp_table.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/hid/bpf/hid_bpf_jmp_table.c b/drivers/hid/bpf/hid_bpf_jmp_table.c index e5f171ab480c..bfcdd7b805a9 100644 --- a/drivers/hid/bpf/hid_bpf_jmp_table.c +++ b/drivers/hid/bpf/hid_bpf_jmp_table.c @@ -122,8 +122,10 @@ int hid_bpf_prog_run(struct hid_device *hdev, enum hid_bpf_prog_type type, ctx_kern->ctx.index = idx; err = __hid_bpf_tail_call(&ctx_kern->ctx); - if (err) + if (err < 0) break; + if (err) + ctx_kern->ctx.retval = err; } out_unlock: |