]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
i2c: designware: Fix an error handling path in i2c_dw_pci_probe()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Tue, 13 May 2025 17:56:41 +0000 (19:56 +0200)
committerAndi Shyti <andi.shyti@kernel.org>
Wed, 14 May 2025 15:28:24 +0000 (17:28 +0200)
If navi_amd_register_client() fails, the previous i2c_dw_probe() call
should be undone by a corresponding i2c_del_adapter() call, as already done
in the remove function.

Fixes: 17631e8ca2d3 ("i2c: designware: Add driver support for AMD NAVI GPU")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: <stable@vger.kernel.org> # v5.13+
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/fcd9651835a32979df8802b2db9504c523a8ebbb.1747158983.git.christophe.jaillet@wanadoo.fr
drivers/i2c/busses/i2c-designware-pcidrv.c

index 8e0267c7cc294ee0ffe49d733b010b6c24544a5f..f21f9877c04047949ff3937fe955e6ffdfabbbc0 100644 (file)
@@ -278,9 +278,11 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
 
        if ((dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) {
                dev->slave = i2c_new_ccgx_ucsi(&dev->adapter, dev->irq, &dgpu_node);
-               if (IS_ERR(dev->slave))
+               if (IS_ERR(dev->slave)) {
+                       i2c_del_adapter(&dev->adapter);
                        return dev_err_probe(device, PTR_ERR(dev->slave),
                                             "register UCSI failed\n");
+               }
        }
 
        pm_runtime_set_autosuspend_delay(device, 1000);