summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.com>2026-08-14 14:47:35 +0200
committerJiri Kosina <jkosina@suse.com>2026-08-14 14:47:35 +0200
commitf4b6918a335de51f5612e7db05f6dce316860464 (patch)
tree4aed9e839ace7db5f4bf4a1d87a8411934c201cf /scripts
parent8f51abaa0045860880292abfa9bdd7f0633af7a0 (diff)
parent7939f787f450d9390477afba2540c0962c6cb643 (diff)
downloadlinux-next-f4b6918a335de51f5612e7db05f6dce316860464.tar.gz
linux-next-f4b6918a335de51f5612e7db05f6dce316860464.zip
Merge branch 'for-7.3/core' into for-next
Diffstat (limited to 'scripts')
-rw-r--r--scripts/coccinelle/hid/ff_race.cocci34
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/coccinelle/hid/ff_race.cocci b/scripts/coccinelle/hid/ff_race.cocci
new file mode 100644
index 000000000000..479f5d1e3184
--- /dev/null
+++ b/scripts/coccinelle/hid/ff_race.cocci
@@ -0,0 +1,34 @@
+/// 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@
+identifier probe_fn;
+expression hdev, flags;
+position p1, p2;
+@@
+
+probe_fn(struct hid_device *hdev, ...) {
+ <...
+ hid_hw_start@p1(hdev, flags)
+ ...
+ \(input_ff_create\|input_ff_create_memless\)@p2(...)
+ ...>
+}
+
+@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)