From: sashiko-bot@kernel.org
To: "Bishwa Bhusan Saha" <contact@bishwasaha.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v2 2/5] HID: UNCTRL: add basic battery reporting for UNCTRL RAGE Mouse
Date: Mon, 12 Oct 2026 21:20:16 +0000 [thread overview]
Message-ID: <sashiko-outbox-168615@kernel.org> (raw)
In-Reply-To: <20261013-b4-unctrl-m1-battery-v2-2-bd6752021753@bishwasaha.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] hid: unbalanced hid_hw_close() in unctrl_remove() for non-vendor interfaces
--
commit 34f6450fbc06f0259d8e3dc8b22b5c1567b8c302
Author: Bishwa Bhusan Saha <contact@bishwasaha.com>
HID: UNCTRL: add basic battery reporting for UNCTRL RAGE Mouse
This initial patch will probe the battery only once. A later patch
will add periodic checking.
> diff --git a/drivers/hid/hid-unctrl-m1.c b/drivers/hid/hid-unctrl-m1.c
> new file mode 100644
> index 0000000000000..3896468adf77f
> --- /dev/null
> +++ b/drivers/hid/hid-unctrl-m1.c
[ ... ]
> +static int unctrl_probe(struct hid_device *hdev, const struct hid_device_id *id)
> +{
[ ... ]
> + ret = hid_hw_start(hdev, connect_mask);
> + if (ret) {
> + hid_err(hdev, "%s:hw start failed with error %d\n", __func__,
> + ret);
> + return ret;
> + }
> +
> + if (!vendor)
> + return 0;
> +
> + dev = kzalloc_obj(*dev);
[ ... ]
> + /* usbhid polls the interrupt in endpoint only while it is open */
> + ret = hid_hw_open(hdev);
[ ... ]
> +static void unctrl_remove(struct hid_device *hdev)
> +{
> + struct unctrl_dev *dev = hid_get_drvdata(hdev);
> +
> + hid_hw_close(hdev);
[Severity: High]
Does this code cause a hardware reference count underflow for non-vendor
interfaces?
When the driver binds to a non-vendor interface, unctrl_probe() correctly
returns 0 early without calling hid_hw_open() or allocating the private
dev struct. However, upon driver unbind, unctrl_remove() unconditionally
calls hid_hw_close() before checking if dev is NULL.
Any hot-unplug, module unload, or manual driver unbind of a non-vendor
interface will trigger this unbalanced close, underflowing the
hdev->ll_open_count. This corrupts the transport open state and prevents
the device from being properly opened subsequently (e.g., by hidraw or
hidinput).
> +
> + hid_hw_stop(hdev);
> +
> + if (!dev)
> + return;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261013-b4-unctrl-m1-battery-v2-0-bd6752021753@bishwasaha.com?part=2
next prev parent reply other threads:[~2026-10-12 21:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 21:13 [PATCH v2 0/5] HID: add battery driver for the UNCTRL RAGE Wireless Mouse Bishwa Bhusan Saha via B4 Relay
2026-10-12 21:13 ` Bishwa Bhusan Saha
2026-10-12 21:13 ` [PATCH v2 1/5] HID: add IDs for UNCTRL RAGE Mouse Bishwa Bhusan Saha via B4 Relay
2026-10-12 21:13 ` Bishwa Bhusan Saha
2026-10-12 21:13 ` [PATCH v2 2/5] HID: UNCTRL: add basic battery reporting " Bishwa Bhusan Saha via B4 Relay
2026-10-12 21:13 ` Bishwa Bhusan Saha
2026-10-12 21:20 ` sashiko-bot [this message]
2026-10-12 21:13 ` [PATCH v2 3/5] HID: UNCTRL: add periodic battery reporting using a workqueue Bishwa Bhusan Saha via B4 Relay
2026-10-12 21:13 ` Bishwa Bhusan Saha
2026-10-12 21:13 ` [PATCH v2 4/5] HID: UNCTRL: keep a single battery when a mouse has multiple connections Bishwa Bhusan Saha via B4 Relay
2026-10-12 21:13 ` Bishwa Bhusan Saha
2026-10-12 21:27 ` sashiko-bot
2026-10-12 21:14 ` [PATCH v2 5/5] HID: UNCTRL: only report to userspace on battery changes Bishwa Bhusan Saha via B4 Relay
2026-10-12 21:14 ` Bishwa Bhusan Saha
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=sashiko-outbox-168615@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=contact@bishwasaha.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--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.