From: sashiko-bot@kernel.org
To: "Dmitry Antipov" <dmantipov@yandex.ru>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v2 2/2] HID: usbhid: free unsent raw output reports in usbhid_stop()
Date: Wed, 19 Aug 2026 11:34:27 +0000 [thread overview]
Message-ID: <20260819113428.1E1301F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260819111203.2883239-2-dmantipov@yandex.ru>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Emptying the `out` queue in `usbhid_stop` without updating the corresponding `hid_irq_out` completion handler causes an out-of-bounds queue access, leading to a NULL pointer dereference and kernel panic.
--
--- Patch [2]: [PATCH v2 2/2] HID: usbhid: free unsent raw output reports in usbhid_stop() ---
commit 026e2d1c35a0ae9588e9e7e4b956512ff4689607
Author: Dmitry Antipov <dmantipov@yandex.ru>
HID: usbhid: free unsent raw output reports in usbhid_stop()
When a HID device is stalled or disconnected, there might be unsent
output reports. This patch frees their raw buffers in usbhid_stop()
to avoid memory leaks.
Closes: https://syzkaller.appspot.com/bug?extid=e2c057ea576d2644e2be
> diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
> index 96b0181cf8194..60662616fd2a0 100644
> --- a/drivers/hid/usbhid/hid-core.c
> +++ b/drivers/hid/usbhid/hid-core.c
> @@ -1253,6 +1253,14 @@ static void usbhid_stop(struct hid_device *hid)
> usbhid->ctrltail = (usbhid->ctrltail + 1) &
> (HID_CONTROL_FIFO_SIZE - 1);
> }
> +
> + while (usbhid->outtail != usbhid->outhead) {
> + kfree(usbhid->out[usbhid->outtail].raw_report);
> + usbhid->out[usbhid->outtail].raw_report = NULL;
> +
> + usbhid->outtail = (usbhid->outtail + 1) &
> + (HID_OUTPUT_FIFO_SIZE - 1);
> + }
[Severity: High]
Could emptying the out queue here cause a NULL pointer dereference if an
output URB is currently in-flight?
If an in-flight URB is canceled by the subsequent usb_kill_urb() call, it
will synchronously trigger the completion handler hid_irq_out() with status
-ENOENT.
Unlike hid_ctrl(), hid_irq_out() unconditionally increments outtail:
drivers/hid/usbhid/hid-core.c:hid_irq_out() {
...
} else {
usbhid->outtail = (usbhid->outtail + 1) & (HID_OUTPUT_FIFO_SIZE - 1);
if (usbhid->outhead != usbhid->outtail &&
hid_submit_out(hid) == 0) {
...
}
If usbhid_stop() has already made outtail equal to outhead, this increment
pushes outtail out of bounds. The outhead != outtail check will then pass,
and it will call hid_submit_out() which will dereference a NULL report:
drivers/hid/usbhid/hid-core.c:hid_submit_out() {
...
report = usbhid->out[usbhid->outtail].report;
usbhid->urbout->transfer_buffer_length = hid_report_len(report);
...
}
> spin_unlock_irq(&usbhid->lock);
>
> usb_kill_urb(usbhid->urbin);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260819111203.2883239-1-dmantipov@yandex.ru?part=2
next prev parent reply other threads:[~2026-08-19 11:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 11:12 [PATCH v2 1/2] HID: usbhid: adjust output pipe FIFO size Dmitry Antipov
2026-08-19 11:12 ` [PATCH v2 2/2] HID: usbhid: free unsent raw output reports in usbhid_stop() Dmitry Antipov
2026-08-19 11:34 ` sashiko-bot [this message]
2026-08-19 11:35 ` [PATCH v2 1/2] HID: usbhid: adjust output pipe FIFO size 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=20260819113428.1E1301F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmantipov@yandex.ru \
--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.