[PATCH v2] i2c: pxa: fix call balance of i2c->clk handling routines

From: Vitalii Mordan
Date: Wed Feb 12 2025 - 12:28:37 EST


If the clock i2c->clk was not enabled in i2c_pxa_probe(), it should not be
disabled in any path.

Found by Linux Verification Center (linuxtesting.org) with Klever.
Signed-off-by: Vitalii Mordan <mordan@xxxxxxxxx>
---
v2: Use dev_err_probe() helper function, as per Andi Shyti request.
drivers/i2c/busses/i2c-pxa.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index cb6988482673..c4e938c667f0 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -1503,7 +1503,11 @@ static int i2c_pxa_probe(struct platform_device *dev)
i2c->adap.name);
}

- clk_prepare_enable(i2c->clk);
+ ret = clk_prepare_enable(i2c->clk);
+ if (ret) {
+ return dev_err_probe(&dev->dev, ret,
+ "failed to enable clock\n");
+ }

if (i2c->use_pio) {
i2c->adap.algo = &i2c_pxa_pio_algorithm;
--
2.25.1