[PATCH v2 06/20] Input: rmi4 - iterative IRQ handler
From: Dmitry Torokhov
Date: Tue May 05 2026 - 01:01:45 EST
The current IRQ handler uses recursion to drain the attention FIFO,
which can lead to stack overflow on deep queues. Convert it to a
loop.
Fixes: b908d3cd812a ("Input: synaptics-rmi4 - allow to add attention data")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/input/rmi4/rmi_driver.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index d873c7f08e42..c2843c21f0b9 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -198,24 +198,24 @@ static irqreturn_t rmi_irq_fn(int irq, void *dev_id)
struct rmi4_attn_data attn_data = {0};
int ret, count;
- count = kfifo_get(&drvdata->attn_fifo, &attn_data);
- if (count) {
- *(drvdata->irq_status) = attn_data.irq_status;
- drvdata->attn_data = attn_data;
- }
-
- ret = rmi_process_interrupt_requests(rmi_dev);
- if (ret)
- rmi_dbg(RMI_DEBUG_CORE, &rmi_dev->dev,
- "Failed to process interrupt request: %d\n", ret);
+ do {
+ count = kfifo_get(&drvdata->attn_fifo, &attn_data);
+ if (count) {
+ *drvdata->irq_status = attn_data.irq_status;
+ drvdata->attn_data = attn_data;
+ }
- if (count) {
- kfree(attn_data.data);
- drvdata->attn_data.data = NULL;
- }
+ ret = rmi_process_interrupt_requests(rmi_dev);
+ if (ret)
+ rmi_dbg(RMI_DEBUG_CORE, &rmi_dev->dev,
+ "Failed to process interrupt request: %d\n",
+ ret);
- if (!kfifo_is_empty(&drvdata->attn_fifo))
- return rmi_irq_fn(irq, dev_id);
+ if (count) {
+ kfree(attn_data.data);
+ drvdata->attn_data.data = NULL;
+ }
+ } while (!kfifo_is_empty(&drvdata->attn_fifo));
return IRQ_HANDLED;
}
--
2.54.0.545.g6539524ca2-goog