[PATCH] i2c: mv64xxx: Check clk_prepare_enable() return value in runtime resume
From: Tang Bin
Date: Mon Oct 26 2026 - 07:41:40 EST
mv64xxx_i2c_runtime_resume() calls clk_prepare_enable() for both
drv_data->clk and drv_data->reg_clk without checking the return value.
If either clock fails to enable, the function returns 0 (success) and
the driver proceeds to call reset_control_reset() and
mv64xxx_i2c_hw_init() which access hardware registers without clocks
enabled, potentially causing a bus hang.
Additionally, if the second clk_prepare_enable() fails, the first clock
is left enabled without being disabled on the error path.
Fix this by checking both return values and properly cleaning up the
first clock if the second fails.
Fixes: e5c02cf54154 ("i2c: mv64xxx: Add runtime PM support")
Signed-off-by: Tang Bin <tangbin@xxxxxxxxxxxxxxxxxxxx>
---
drivers/i2c/busses/i2c-mv64xxx.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 1acba628e..62a564556 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -963,9 +963,18 @@ static int
mv64xxx_i2c_runtime_resume(struct device *dev)
{
struct mv64xxx_i2c_data *drv_data = dev_get_drvdata(dev);
+ int ret;
+
+ ret = clk_prepare_enable(drv_data->clk);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(drv_data->reg_clk);
+ if (ret) {
+ clk_disable_unprepare(drv_data->clk);
+ return ret;
+ }
- clk_prepare_enable(drv_data->clk);
- clk_prepare_enable(drv_data->reg_clk);
reset_control_reset(drv_data->rstc);
mv64xxx_i2c_hw_init(drv_data);
--
2.52.0.windows.1