Coccinelle Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: "Jiri Kosina" <jikos@kernel.org>,
	"Benjamin Tissoires" <bentiss@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Nicolas Palix" <nicolas.palix@imag.fr>,
	"Filipe Laíns" <lains@riseup.net>,
	"Bastien Nocera" <hadess@hadess.net>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, cocci@inria.fr
Subject: Re: [cocci] [PATCH 02/21] HID: add documentation and Coccinelle script for FF registration race
Date: Sun, 16 Aug 2026 21:03:40 -0700	[thread overview]
Message-ID: <aoKDE_9t4yYLdmCt@google.com> (raw)
In-Reply-To: <5e96c91-164f-9ec5-43e4-474189e2a337@inria.fr>

On Sun, Aug 16, 2026 at 08:52:51PM +0200, Julia Lawall wrote:
> > 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(...)
> > +  ...>
> > +}
> 
> 
> This seems unnecessarily costly.  The pattern can be just:
> 
> hid_hw_start@p1(hdev, flags)
> ...
> \(input_ff_create\|input_ff_create_memless\)@p2(...)
> 
> Or does it matter that struct hid_device *hdev is the first parameter
> of the enclosing function?
> 

I guess not. I was trying to limit the check to what looks like HID
driver probe function, but that would miss similar issues in helpers
that use different order or set of arguments.

Thanks.

-- 
Dmitry

  reply	other threads:[~2026-08-17  7:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260803-hid-ff-input-configured-v1-0-1dc9bbacd88c@gmail.com>
2026-08-14 12:47 ` [cocci] [PATCH 00/21] HID: fix racy force feedback initialization via .input_configured() Jiri Kosina
     [not found] ` <20260803-hid-ff-input-configured-v1-2-1dc9bbacd88c@gmail.com>
2026-08-16 18:52   ` [cocci] [PATCH 02/21] HID: add documentation and Coccinelle script for FF registration race Julia Lawall
2026-08-17  4:03     ` Dmitry Torokhov [this message]
2026-08-18 12:04   ` [cocci] " Ricardo Ribalda
2026-08-18 12:08     ` Julia Lawall
2026-08-27  9:39       ` Ricardo Ribalda
2026-08-27  9:45       ` Ricardo Ribalda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aoKDE_9t4yYLdmCt@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=cocci@inria.fr \
    --cc=corbet@lwn.net \
    --cc=hadess@hadess.net \
    --cc=jikos@kernel.org \
    --cc=julia.lawall@inria.fr \
    --cc=lains@riseup.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.palix@imag.fr \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox