[PATCH] i2c: cs75xx: Disable the controller before releasing its IRQ

From: Fil Dunsky via B4 Relay

Date: Fri Nov 27 2026 - 14:03:40 EST


From: Fil Dunsky <filipp.dunsky@xxxxxxxxx>

Managed resources are released in reverse registration order. Registering
the disable action before the IRQ causes free_irq() to run while the
controller is still enabled during probe failure or driver removal.

Register the disable action after devm_request_irq() so that the adapter
is removed first, then the interrupt source is disabled, and finally the
handler is freed and synchronized before the clock and mapping disappear.
Disable the controller explicitly if requesting the IRQ fails.

Fixes: 3fdb0e8ef0d4 ("i2c: Add Cortina Systems CS75xx I2C controller driver")
Signed-off-by: Fil Dunsky <filipp.dunsky@xxxxxxxxx>
---
This is a focused follow-up to the driver accepted in i2c/i2c as
3fdb0e8ef0d4, rather than a reroll of the complete I2C series.

Move the managed disable action after the IRQ registration, and disable
the configured controller explicitly if requesting the IRQ fails. The
adapter is removed before the source is disabled, then free_irq() drains
any handler before the clock and register mapping are released.

The driver postimage matches the correction already compiled in native
ARM and OpenWrt 6.18.64 builds and installed on Almond+. Focused tests
using the actual cleanup source cover successful teardown, request_irq
failure, action-registration failure and adapter-registration failure.
No hardware fault injection is claimed.
---
drivers/i2c/busses/i2c-cs75xx.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cs75xx.c b/drivers/i2c/busses/i2c-cs75xx.c
index 49a14f27b..c5365448c 100644
--- a/drivers/i2c/busses/i2c-cs75xx.c
+++ b/drivers/i2c/busses/i2c-cs75xx.c
@@ -344,12 +344,15 @@ static int cs75xx_i2c_probe(struct platform_device *pdev)
writel(0, i2c->base + CS75XX_I2C_IE);
writel(CS75XX_I2C_INT_DONE, i2c->base + CS75XX_I2C_INT);

- ret = devm_add_action_or_reset(dev, cs75xx_i2c_disable, i2c);
- if (ret)
- return ret;
-
ret = devm_request_irq(dev, i2c->irq, cs75xx_i2c_isr, 0, dev_name(dev),
i2c);
+ if (ret) {
+ cs75xx_i2c_disable(i2c);
+ return ret;
+ }
+
+ /* Quiesce the source before devres releases the interrupt handler. */
+ ret = devm_add_action_or_reset(dev, cs75xx_i2c_disable, i2c);
if (ret)
return ret;


---
base-commit: 3fdb0e8ef0d477ce4b9a9c5ebd370e64d7ae4ed8
change-id: 20261127-i2c-cs75xx-irq-teardown-5a062ec51512

Best regards,
--
Fil Dunsky <filipp.dunsky@xxxxxxxxx>