lkml.org 
[lkml]   [2022]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH bpf-next v2 03/28] HID: hook up with bpf
    On Fri, Mar 4, 2022 at 9:31 AM Benjamin Tissoires
    <benjamin.tissoires@redhat.com> wrote:
    >
    > Now that BPF can be compatible with HID, add the capability into HID.
    > drivers/hid/hid-bpf.c takes care of the glue between bpf and HID, and
    > hid-core can then inject any incoming event from the device into a BPF
    > program to filter/analyze it.
    >
    > Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
    >
    [...]

    > +
    > +static int hid_bpf_link_attach(struct hid_device *hdev, enum bpf_hid_attach_type type)
    > +{
    > + int err = 0;
    > +
    > + switch (type) {
    > + case BPF_HID_ATTACH_DEVICE_EVENT:
    > + if (!hdev->bpf.ctx) {
    > + hdev->bpf.ctx = bpf_hid_allocate_ctx(hdev, HID_BPF_MAX_BUFFER_SIZE);
    > + if (IS_ERR(hdev->bpf.ctx)) {
    > + err = PTR_ERR(hdev->bpf.ctx);
    > + hdev->bpf.ctx = NULL;
    > + }
    > + }
    > + break;
    > + default:
    > + /* do nothing */

    Do we need to show warning and/or return EINVAL here?

    > + }
    > +
    > + return err;
    > +}
    > +
    > +static void hid_bpf_array_detached(struct hid_device *hdev, enum bpf_hid_attach_type type)
    > +{
    > + switch (type) {
    > + case BPF_HID_ATTACH_DEVICE_EVENT:
    > + kfree(hdev->bpf.ctx);
    > + hdev->bpf.ctx = NULL;
    > + break;
    > + default:
    > + /* do nothing */

    ditto

    [...]

    \
     
     \ /
      Last update: 2022-03-05 01:24    [W:4.785 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site