[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMFT1=Y+hNB3-oR2rLPKshd1US_W6gTWbt1o5mvoL8ysH2=nNw@mail.gmail.com>
Date: Mon, 9 Feb 2026 00:58:48 -0600
From: Ziyi Guo <n7l8m4@...orthwestern.edu>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc: linux-input@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Input: cyapa - fix missing input->mutex when calling input_device_enabled()
On Tue, Feb 3, 2026 at 3:52 AM Dmitry Torokhov
<dmitry.torokhov@...il.com> wrote:
>
> The driver requires much more through conversion to handle potential
> races with opening and closing the input device.
>
> Thanks.
>
> --
> Dmitry
Hi Dmitry,
Thank you for your time and comments.
How about we go with an alternative approach, add a bool input_opened
field to struct cyapa, set it in cyapa_open() and clear it in
cyapa_close(), then replace input_device_enabled(input) with
cyapa->input_opened.
I guess this work because
- The input core calls dev->open() exactly when input_device_enabled()
transitions to true (first user open, uninhibit with users), and
dev->close()
exactly when it transitions to false (last user close, inhibit with
users). So the flag mirrors input_device_enabled().
- cyapa_open() and cyapa_close() both hold state_sync_lock when
setting the flag. All callers of cyapa_enable_irq_for_cmd(),
cyapa_disable_irq_for_cmd(), and cyapa_reinitialize() that can
reach the flag also hold state_sync_lock, so the check and the
subsequent action (power mode change, IRQ enable/disable) are atomic,
no TOCTOU window.
Thank you again!
Powered by blists - more mailing lists