]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
i2c: core: fix adapter probe deferral loop
authorJohan Hovold <johan@kernel.org>
Mon, 11 May 2026 14:37:09 +0000 (16:37 +0200)
committerWolfram Sang <wsa+renesas@sang-engineering.com>
Sat, 30 May 2026 21:57:19 +0000 (23:57 +0200)
Drivers must not probe defer after having registered devices as that
will trigger a probe loop if the devices bind to a driver (cf. commit
fbc35b45f9f6 ("Add documentation on meaning of -EPROBE_DEFER")).

Move the recovery initialisation, where the GPIO lookup may fail, before
registering the adapter to prevent this.

Fixes: 75820314de26 ("i2c: core: add generic I2C GPIO recovery")
Cc: stable@vger.kernel.org # 5.9
Cc: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
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 fa9db415e21980b592bfb0b7e43ba0f8628bb229..1caaa3b3ee10522466101d3145e412620c0327f8 100644 (file)
@@ -1562,6 +1562,10 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
        adap->dev.type = &i2c_adapter_type;
        device_initialize(&adap->dev);
 
+       res = i2c_init_recovery(adap);
+       if (res == -EPROBE_DEFER)
+               goto err_put_adap;
+
        /*
         * This adapter can be used as a parent immediately after device_add(),
         * setup runtime-pm (especially ignore-children) before hand.
@@ -1583,10 +1587,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
        if (res)
                goto out_reg;
 
-       res = i2c_init_recovery(adap);
-       if (res == -EPROBE_DEFER)
-               goto out_reg;
-
        dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name);
 
        /* create pre-declared device nodes */