From: sashiko-bot@kernel.org
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH 09/11] Input: ims-pcu - fix DMA mapping violation in line setup
Date: Sat, 23 May 2026 05:37:04 +0000 [thread overview]
Message-ID: <20260523053704.BD63A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260523050634.501509-9-dmitry.torokhov@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Using GFP_KERNEL in a function called from a USB resume callback risks system deadlocks during suspend/resume.
Pre-existing issues:
- [High] Mismatch between allocation and free sizes for coherent DMA memory.
--
commit ecb1961e66f5ce58ee717e51a89fafeaebd53f86
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Input: ims-pcu - fix DMA mapping violation in line setup
This commit fixes a DMA mapping alignment violation by replacing the
embedded pcu->cmd_buf with a dynamically allocated buffer for line coding
data.
Fixes: 628329d52474 ("Input: add IMS Passenger Control Unit driver")
Cc: stable@vger.kernel.org
Reported-by: Sashiko bot <sashiko-bot@kernel.org>
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
> index d7a3f4c7214a0..7746a8242f2a0 100644
> --- a/drivers/input/misc/ims-pcu.c
> +++ b/drivers/input/misc/ims-pcu.c
> @@ -1790,11 +1790,16 @@ static void ims_pcu_stop_io(struct ims_pcu *pcu)
> static int ims_pcu_line_setup(struct ims_pcu *pcu)
> {
> struct usb_host_interface *interface = pcu->ctrl_intf->cur_altsetting;
> - struct usb_cdc_line_coding *line = (void *)pcu->cmd_buf;
> + struct usb_cdc_line_coding *line __free(kfree) =
> + kmalloc(sizeof(*line), GFP_KERNEL);
[Severity: High]
Does allocating memory with GFP_KERNEL here risk a system deadlock during
suspend/resume?
Since ims_pcu_line_setup() is called by the USB power management callback
ims_pcu_resume():
ims_pcu_resume() {
if (alt->desc.bInterfaceClass == USB_CLASS_COMM) {
retval = ims_pcu_start_io(pcu);
if (retval == 0)
retval = ims_pcu_line_setup(pcu);
}
}
During the system resume phase, device locks are held by the PM core. Using
GFP_KERNEL allows direct reclaim, which can initiate filesystem and block I/O.
If these operations attempt to access a suspended device or wait on a shared
lock, it could block indefinitely. Should this use GFP_NOIO instead?
> int error;
>
> - memset(line, 0, sizeof(*line));
> + if (!line)
> + return -ENOMEM;
> +
> line->dwDTERate = cpu_to_le32(57600);
> + line->bCharFormat = USB_CDC_1_STOP_BITS;
> + line->bParityType = USB_CDC_NO_PARITY;
> line->bDataBits = 8;
>
[ ... ]
[Severity: High]
This isn't a bug introduced by this patch, but is there a mismatch between the
allocation and free sizes for the coherent DMA memory?
Looking at ims_pcu_buffers_alloc(), pcu->urb_in_buf is dynamically allocated
with a size of pcu->max_in_size:
ims_pcu_buffers_alloc() {
...
pcu->urb_in_buf = usb_alloc_coherent(pcu->udev, pcu->max_in_size,
GFP_KERNEL, &pcu->read_dma);
...
}
However, in ims_pcu_buffers_free(), the same buffer is freed using
pcu->max_out_size instead:
ims_pcu_buffers_free() {
...
usb_free_coherent(pcu->udev, pcu->max_out_size,
pcu->urb_in_buf, pcu->read_dma);
...
}
Since max_in_size and max_out_size are initialized independently from their
respective endpoint descriptors, they can differ. Can passing the incorrect
size to usb_free_coherent() result in memory corruption or page leaks?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260523050634.501509-1-dmitry.torokhov@gmail.com?part=9
next prev parent reply other threads:[~2026-05-23 5:37 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-23 5:06 [PATCH 01/11] Input: ims-pcu - release data interface on disconnect Dmitry Torokhov
2026-05-23 5:06 ` [PATCH 02/11] Input: ims-pcu - fix use-after-free and double-free in disconnect Dmitry Torokhov
2026-05-23 5:45 ` sashiko-bot
2026-05-23 5:06 ` [PATCH 03/11] Input: ims-pcu - fix type confusion in CDC union descriptor parsing Dmitry Torokhov
2026-05-23 5:52 ` sashiko-bot
2026-05-23 5:06 ` [PATCH 04/11] Input: ims-pcu - fix firmware leak in async update Dmitry Torokhov
2026-05-23 5:37 ` sashiko-bot
2026-05-23 5:06 ` [PATCH 05/11] Input: ims-pcu - fix race condition in reset_device sysfs callback Dmitry Torokhov
2026-05-23 7:12 ` sashiko-bot
2026-05-23 5:06 ` [PATCH 06/11] Input: ims-pcu - validate control endpoint type Dmitry Torokhov
2026-05-23 5:44 ` sashiko-bot
2026-05-23 5:06 ` [PATCH 07/11] Input: ims-pcu - fix logic error in packet reset Dmitry Torokhov
2026-05-23 6:25 ` sashiko-bot
2026-05-23 5:06 ` [PATCH 08/11] Input: ims-pcu - fix out-of-bounds read in ims_pcu_irq() debug logging Dmitry Torokhov
2026-05-23 5:39 ` sashiko-bot
2026-05-23 5:06 ` [PATCH 09/11] Input: ims-pcu - fix DMA mapping violation in line setup Dmitry Torokhov
2026-05-23 5:37 ` sashiko-bot [this message]
2026-05-23 5:06 ` [PATCH 10/11] Input: ims-pcu - add response length checks Dmitry Torokhov
2026-05-23 5:54 ` sashiko-bot
2026-05-23 5:06 ` [PATCH 11/11] Input: ims-pcu - fix potential infinite loop in CDC union descriptor parsing Dmitry Torokhov
2026-05-23 6:02 ` sashiko-bot
2026-05-23 5:46 ` [PATCH 01/11] Input: ims-pcu - release data interface on disconnect 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=20260523053704.BD63A1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox