]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
i2c: core: fix irq domain leak on adapter registration failure
authorJohan Hovold <johan@kernel.org>
Mon, 11 May 2026 14:37:06 +0000 (16:37 +0200)
committerWolfram Sang <wsa+renesas@sang-engineering.com>
Sat, 30 May 2026 21:57:18 +0000 (23:57 +0200)
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>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
drivers/i2c/i2c-core-base.c

index 9c46147e3506d15d53b9b7d6b592709de56e41b9..abe8341c1d6e6dc6fabfe9f282ec6a8618275e17 100644 (file)
@@ -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 @@ out_reg:
        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);