All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Méven Car" <meven29@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v2] HID: logitech-headset: add a battery driver for the PRO X 2
Date: Fri, 11 Sep 2026 12:10:57 +0000	[thread overview]
Message-ID: <20260911121058.3B7DE1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911120208.21698-1-meven@kde.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The driver cancels its delayed workqueue before calling hid_hw_stop(), which violates the mandatory HID subsystem cleanup order.
--

commit bd334ae3e07d607cf268d197e4923d3fe7f27cad
Author: Méven Car <meven29@gmail.com>

HID: logitech-headset: add a battery driver for the PRO X 2
    
This commit introduces a battery driver for the Logitech PRO X 2 LIGHTSPEED
headset. The device reports its battery status over a vendor collection
rather than HID++, so a custom driver is implemented to poll and parse these
reports.

> diff --git a/drivers/hid/hid-logitech-headset.c b/drivers/hid/hid-logitech-headset.c
> new file mode 100644
> index 0000000000000..9081ddf5f42f2
> --- /dev/null
> +++ b/drivers/hid/hid-logitech-headset.c
[ ... ]
> +static void logi_headset_remove(struct hid_device *hdev)
> +{
> +	struct logi_headset *headset = hid_get_drvdata(hdev);
> +
> +	cancel_delayed_work_sync(&headset->poll);
> +	hid_hw_close(hdev);
> +	hid_hw_stop(hdev);

[Severity: High]
Could this teardown sequence in logi_headset_remove() lead to a
use-after-free?

In drivers/hid/hid-logitech-headset.c:logi_headset_remove(), the delayed work
is cancelled before hid_hw_stop() is called. When a device is unplugged or
unbound, cancelling workers before stopping the hardware (which unregisters
the device interfaces) means that hardware events or userspace interactions
could theoretically queue new work after the cancellation.

Since devres automatically frees the driver's private data after remove()
returns, any lingering work executing subsequently would access freed memory.
Calling hid_hw_stop() before cancelling the work would ensure no new work can
be queued.

> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260911120208.21698-1-meven@kde.org?part=1

  reply	other threads:[~2026-09-11 12:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 11:53 [PATCH] HID: logitech-headset: add a battery driver for the PRO X 2 Méven Car
2026-09-11 12:02 ` [PATCH v2] " Méven Car
2026-09-11 12:10   ` sashiko-bot [this message]
2026-09-11 13:53     ` Méven
2026-09-11 12:02 ` [PATCH] " sashiko-bot

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=20260911121058.3B7DE1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=meven29@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.