mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
Replace "expression" with "identifier" in the declaration of hdev. This is necessary because hdev is used as the name of a function parameter. Move the two uses of @p2 to the relevant function names. Convert <... ...>, meaning that the contained pattern is optional, to use ..., when any, and exists. This requires that the function contain calls to hid_hw_start, etc, which reduces the set of files that are considered for matching against this pattern. Reported-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> Signed-off-by: Jiri Kosina <jkosina@suse.com>
36 lines
1.0 KiB
Plaintext
36 lines
1.0 KiB
Plaintext
/// Detect HID drivers that initialize force-feedback after hid_hw_start()
|
|
/// when HID_CONNECT_HIDINPUT is used. This is a lifecycle violation as
|
|
/// the input device is already registered.
|
|
//
|
|
// Confidence: High
|
|
// Copyright: (C) 2026 Gemini. GPLv2.
|
|
|
|
virtual report
|
|
|
|
@r exists@
|
|
identifier probe_fn;
|
|
identifier hdev;
|
|
expression flags;
|
|
position p1, p2;
|
|
@@
|
|
|
|
probe_fn(struct hid_device *hdev, ...) {
|
|
... when any
|
|
hid_hw_start@p1(hdev, flags)
|
|
...
|
|
\(input_ff_create@p2\|input_ff_create_memless@p2\)(...)
|
|
... when any
|
|
}
|
|
|
|
@script:python depends on report@
|
|
p1 << r.p1;
|
|
p2 << r.p2;
|
|
flags << r.flags;
|
|
@@
|
|
|
|
# Check if flags include HID_CONNECT_HIDINPUT (0x01) or HID_CONNECT_DEFAULT (0x0f)
|
|
# Note: HID_CONNECT_DEFAULT is 0x0f, HID_CONNECT_HIDINPUT is 0x01
|
|
if "HID_CONNECT_HIDINPUT" in flags or "HID_CONNECT_DEFAULT" in flags:
|
|
msg = "WARNING: force-feedback initialized after hid_hw_start() with HID_CONNECT_HIDINPUT. Input device is already registered at this point. Use .input_configured() instead."
|
|
coccilib.report.print_report(p2[0], msg)
|