[PATCH] i2c: designware: Fix an error handling path in i2c_dw_pci_probe()

Christophe JAILLET posted 1 patch 9 months ago
drivers/i2c/busses/i2c-designware-pcidrv.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] i2c: designware: Fix an error handling path in i2c_dw_pci_probe()
Posted by Christophe JAILLET 9 months ago
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>
---
 drivers/i2c/busses/i2c-designware-pcidrv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 8e0267c7cc29..f21f9877c040 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -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);
-- 
2.49.0
Re: [PATCH] i2c: designware: Fix an error handling path in i2c_dw_pci_probe()
Posted by Andi Shyti 9 months ago
Hi Christophe,

On Tue, May 13, 2025 at 07:56:41PM +0200, Christophe JAILLET wrote:
> 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>

merged to i2c/i2c-host-fixes.

Thanks,
Andi
Re: [PATCH] i2c: designware: Fix an error handling path in i2c_dw_pci_probe()
Posted by Jarkko Nikula 9 months ago
On 5/13/25 8:56 PM, Christophe JAILLET wrote:
> 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>
> ---
>   drivers/i2c/busses/i2c-designware-pcidrv.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>