Re: [PATCH v2 0/3] Input: raydium_i2c_ts report handling fixes
From: Dmitry Torokhov
Date: Mon Nov 23 2026 - 23:49:41 EST
Hi Pooyan,
On Mon, Sep 28, 2026 at 06:26:15PM +0200, Pooyan Azad wrote:
...
> Patch 2 resizes an existing report buffer when a firmware update changes the
> packet size. Patch 3 moves the initial allocation to the main firmware query
> so devices can remain usable for recovery when they probe in bootloader mode.
There is a teardown ordering issue with using devm_krealloc() in patches 2
and 3.
When a device probes in bootloader mode, ts->report_data has no devres
entry before devm_request_threaded_irq() is called: in patch 2,
devm_kmalloc() with size 0 returns ZERO_SIZE_PTR without calling
devres_add(), and in patch 3, ts->report_data is NULL. When a later
firmware update transitions the controller to main mode and runs
raydium_i2c_query_ts_info(), devm_krealloc() takes its ZERO_OR_NULL_PTR()
fallback to devm_kmalloc() and appends the buffer to the devres list after
the IRQ. On driver unbind, devres releases resources in reverse order,
freeing ts->report_data before free_irq() runs while raydium_i2c_irq() can
still execute.
I do not think we need dynamic allocation for the report buffer at all.
Since pkg_size is a u8 (at most 255 bytes) and raydium_i2c_read() uses
ordinary i2c_transfer() rather than DMA-safe buffers, we can simply embed
"u8 report_data[U8_MAX];" in struct raydium_data. That eliminates the
separate devres allocation, avoids -ENOMEM during firmware updates and
ZERO_SIZE_PTR/NULL handling in bootloader mode, and guarantees the buffer
outlives the IRQ. Patches 2 and 3 then collapse into a single patch
keeping local staging of info/report parameters in
raydium_i2c_query_ts_info() and switching report_data to a fixed-size
array.
While looking at bootloader recovery, note that raydium_i2c_fw_update()
also unconditionally sets ts->boot_mode = RAYDIUM_TS_MAIN even if
raydium_i2c_initialize() returns 0 after seeing RAYDIUM_TS_BLDR, which
can leave contact_size at 0 after a bootloader-mode probe.
Thanks.
--
Dmitry