From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Ziyi Guo <n7l8m4@u.northwestern.edu>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Input: cyapa - fix missing input->mutex when calling input_device_enabled()
Date: Tue, 3 Feb 2026 01:52:24 -0800 [thread overview]
Message-ID: <aYHEzf5nYpA1H5Cj@google.com> (raw)
In-Reply-To: <20260202220223.2471730-1-n7l8m4@u.northwestern.edu>
Hi Ziyi,
On Mon, Feb 02, 2026 at 10:02:23PM +0000, Ziyi Guo wrote:
> cyapa_enable_irq_for_cmd()/cyapa_disable_irq_for_cmd() and
> cyapa_reinitialize call input_device_enabled() without holding
> input->mutex. However, input_device_enabled() has
> lockdep_assert_held(&dev->mutex).
>
> Add mutex_lock()/mutex_unlock() around the input_device_enabled()
> call to properly protect access to the input device state.
>
> Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
> ---
> drivers/input/mouse/cyapa.c | 27 ++++++++++++++++++++++++---
> 1 file changed, 24 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
> index 00c87c0532a6..e5fe3b8b6548 100644
> --- a/drivers/input/mouse/cyapa.c
> +++ b/drivers/input/mouse/cyapa.c
> @@ -525,8 +525,15 @@ static int cyapa_create_input_dev(struct cyapa *cyapa)
> static void cyapa_enable_irq_for_cmd(struct cyapa *cyapa)
> {
> struct input_dev *input = cyapa->input;
> + bool input_enabled = false;
>
> - if (!input || !input_device_enabled(input)) {
> + if (input) {
> + mutex_lock(&input->mutex);
> + input_enabled = input_device_enabled(input);
> + mutex_unlock(&input->mutex);
This solves absolutely nothing. The value of input_enabled becomes stale
the very moment you release the mutex.
The driver requires much more through conversion to handle potential
races with opening and closing the input device.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2026-02-03 9:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-02 22:02 [PATCH] Input: cyapa - fix missing input->mutex when calling input_device_enabled() Ziyi Guo
2026-02-03 9:52 ` Dmitry Torokhov [this message]
2026-02-09 6:58 ` Ziyi Guo
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=aYHEzf5nYpA1H5Cj@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=n7l8m4@u.northwestern.edu \
/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