diff mbox series

[v3,01/10] i2c: core: fix irq domain leak on adapter registration failure

Message ID 20260511143715.729714-2-johan@kernel.org
State Accepted
Delegated to: Wolfram Sang
Headers show
Series i2c: core: adapter registration fixes | expand

Commit Message

Johan Hovold May 11, 2026, 2:37 p.m. UTC
Make sure to tear down the host notify irq domain on adapter
registration failure to avoid leaking it.

This issue was flagged by Sashiko when reviewing another adapter
registration fix.

Fixes: 4d5538f5882a ("i2c: use an IRQ to report Host Notify events, not alert")
Cc: stable@vger.kernel.org	# 4.10
Cc: Benjamin Tissoires <bentiss@kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/i2c/i2c-core-base.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Wolfram Sang June 3, 2026, 9:16 a.m. UTC | #1
On Mon, May 11, 2026 at 04:37:06PM +0200, Johan Hovold wrote:
> Make sure to tear down the host notify irq domain on adapter
> registration failure to avoid leaking it.
> 
> This issue was flagged by Sashiko when reviewing another adapter
> registration fix.
> 
> Fixes: 4d5538f5882a ("i2c: use an IRQ to report Host Notify events, not alert")
> Cc: stable@vger.kernel.org	# 4.10
> Cc: Benjamin Tissoires <bentiss@kernel.org>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
diff mbox series

Patch

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 9c46147e3506..abe8341c1d6e 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1574,7 +1574,7 @@  static int i2c_register_adapter(struct i2c_adapter *adap)
 	if (res) {
 		pr_err("adapter '%s': can't register device (%d)\n", adap->name, res);
 		put_device(&adap->dev);
-		goto out_list;
+		goto err_remove_irq_domain;
 	}
 
 	adap->debugfs = debugfs_create_dir(dev_name(&adap->dev), i2c_debugfs_root);
@@ -1609,6 +1609,8 @@  static int i2c_register_adapter(struct i2c_adapter *adap)
 	init_completion(&adap->dev_released);
 	device_unregister(&adap->dev);
 	wait_for_completion(&adap->dev_released);
+err_remove_irq_domain:
+	i2c_host_notify_irq_teardown(adap);
 out_list:
 	mutex_lock(&core_lock);
 	idr_remove(&i2c_adapter_idr, adap->nr);