From: sashiko-bot@kernel.org
To: "Dmitry Antipov" <dmantipov@yandex.ru>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2 1/2] HID: usbhid: adjust output pipe FIFO size
Date: Wed, 19 Aug 2026 11:35:03 +0000 [thread overview]
Message-ID: <20260819113503.D89E61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260819111203.2883239-1-dmantipov@yandex.ru>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Memory leak of dynamically allocated `raw_report` buffers in the output and control queues upon device unplug and driver unbind.
--
--- Patch [1]: [PATCH v2 1/2] HID: usbhid: adjust output pipe FIFO size ---
commit bf134e3969fdce1c368463a2ad06d7c96d56d312
Author: Dmitry Antipov <dmantipov@yandex.ru>
HID: usbhid: adjust output pipe FIFO size
For an USB-specific HID device, size of output FIFO should
be HID_OUTPUT_FIFO_SIZE rather than HID_CONTROL_FIFO_SIZE.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://syzkaller.appspot.com/bug?extid=e2c057ea576d2644e2be
Fixes: 4916b3a57fc9 ("[PATCH] Generic HID layer - USB API")
> diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h
> index 75fe85d3d27a0..c408e694a7b27 100644
> --- a/drivers/hid/usbhid/usbhid.h
> +++ b/drivers/hid/usbhid/usbhid.h
> @@ -74,7 +74,7 @@ struct usbhid_device {
> unsigned long last_ctrl; /* record of last output for timeouts */
>
> struct urb *urbout; /* Output URB */
> - struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */
> + struct hid_output_fifo out[HID_OUTPUT_FIFO_SIZE]; /* Output pipe fifo */
[Severity: High]
This isn't a bug introduced by this patch, but while adjusting the output
FIFO size, I noticed a pre-existing memory leak related to how these output
and control queues are cleaned up.
In drivers/hid/usbhid/hid-core.c, when a device is physically unplugged,
the URB completion callbacks receive an error and handle it by clearing
the FIFOs.
For example, in hid_irq_out():
if (unplug) {
usbhid->outtail = usbhid->outhead;
} else {
And similarly in hid_ctrl():
if (unplug) {
usbhid->ctrltail = usbhid->ctrlhead;
} else if (usbhid->ctrlhead != usbhid->ctrltail) {
Does this drop the queued items without calling kfree() on their
dynamically allocated raw_report buffers?
Additionally, during driver unbind, usbhid_stop() handles draining the
control queue and correctly freeing raw_report:
while (usbhid->ctrltail != usbhid->ctrlhead) {
if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_OUT) {
kfree(usbhid->ctrl[usbhid->ctrltail].raw_report);
usbhid->ctrl[usbhid->ctrltail].raw_report = NULL;
}
...
}
However, it completely omits an equivalent cleanup loop for the output
queue (usbhid->out).
Could this repeatedly leak memory if userspace or the input subsystem
queues output reports while device unbinds or disconnects occur?
> unsigned char outhead, outtail; /* Output pipe fifo head & tail */
> char *outbuf; /* Output buffer */
> dma_addr_t outbuf_dma; /* Output buffer dma */
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260819111203.2883239-1-dmantipov@yandex.ru?part=1
prev parent reply other threads:[~2026-08-19 11:35 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
2026-08-19 11:35 ` sashiko-bot [this message]
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=20260819113503.D89E61F000E9@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.