* [PATCH] Input: mx25-tcq - clamp the FIFO sample count to the buffer size
@ 2026-11-06 7:51 Liu Chao
2026-11-06 17:36 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Liu Chao @ 2026-11-06 7:51 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Markus Schneider-Pargmann, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Juergen Borleis,
Denis Carikli, Lee Jones, fangxy, linux-input, imx,
linux-arm-kernel, linux-kernel, stable
MX25_ADCQ_SR_FDN() reports up to 31 pending samples. The IRQ thread
aligns the count down to a multiple of the sample count but never
bounds it by the size of sample_buf, so a FIFO backlog larger than
TSC_MAX_SAMPLES overruns the stack buffer.
Clamp the count before the alignment so that the result stays a
multiple of sample_count.
Fixes: 4f7ed234f2a5 ("Input: touchscreen: Add imx25 TCQ driver")
Cc: stable@vger.kernel.org
Signed-off-by: Liu Chao <liuc63@xiaopeng.com>
---
drivers/input/touchscreen/fsl-imx25-tcq.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/input/touchscreen/fsl-imx25-tcq.c b/drivers/input/touchscreen/fsl-imx25-tcq.c
index ff270b3b8572..fa8d8b736723 100644
--- a/drivers/input/touchscreen/fsl-imx25-tcq.c
+++ b/drivers/input/touchscreen/fsl-imx25-tcq.c
@@ -319,6 +319,7 @@ static irqreturn_t mx25_tcq_irq_thread(int irq, void *dev_id)
*/
regmap_read(priv->regs, MX25_ADCQ_SR, &stats);
samples = MX25_ADCQ_SR_FDN(stats);
+ samples = min_t(unsigned int, samples, TSC_MAX_SAMPLES);
samples -= samples % priv->sample_count;
if (!samples)
--
2.50.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] Input: mx25-tcq - clamp the FIFO sample count to the buffer size
2026-11-06 7:51 [PATCH] Input: mx25-tcq - clamp the FIFO sample count to the buffer size Liu Chao
@ 2026-11-06 17:36 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2026-11-06 17:36 UTC (permalink / raw)
To: Liu Chao
Cc: Markus Schneider-Pargmann, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Juergen Borleis,
Denis Carikli, Lee Jones, fangxy, linux-input, imx,
linux-arm-kernel, linux-kernel, stable
Hi Liu,
On Fri, Nov 06, 2026 at 03:51:27PM +0800, Liu Chao wrote:
> MX25_ADCQ_SR_FDN() reports up to 31 pending samples. The IRQ thread
> aligns the count down to a multiple of the sample count but never
> bounds it by the size of sample_buf, so a FIFO backlog larger than
> TSC_MAX_SAMPLES overruns the stack buffer.
>
> Clamp the count before the alignment so that the result stays a
> multiple of sample_count.
>
> Fixes: 4f7ed234f2a5 ("Input: touchscreen: Add imx25 TCQ driver")
> Cc: stable@vger.kernel.org
This is a platform device, not something that can be randomly connected.
SO barring silicon issues the condition should never happen. I do not
think this makes sense to backport this.
> Signed-off-by: Liu Chao <liuc63@xiaopeng.com>
> ---
> drivers/input/touchscreen/fsl-imx25-tcq.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/input/touchscreen/fsl-imx25-tcq.c b/drivers/input/touchscreen/fsl-imx25-tcq.c
> index ff270b3b8572..fa8d8b736723 100644
> --- a/drivers/input/touchscreen/fsl-imx25-tcq.c
> +++ b/drivers/input/touchscreen/fsl-imx25-tcq.c
> @@ -319,6 +319,7 @@ static irqreturn_t mx25_tcq_irq_thread(int irq, void *dev_id)
> */
> regmap_read(priv->regs, MX25_ADCQ_SR, &stats);
> samples = MX25_ADCQ_SR_FDN(stats);
> + samples = min_t(unsigned int, samples, TSC_MAX_SAMPLES);
Why is it valid to clamp instead of refusing invalid data?
> samples -= samples % priv->sample_count;
>
> if (!samples)
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-06 17:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 7:51 [PATCH] Input: mx25-tcq - clamp the FIFO sample count to the buffer size Liu Chao
2026-11-06 17:36 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®