mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 22:54:17 -04:00
i2c: ocores: Disable clock on failed resume
ocores_i2c_resume() enables the controller clock before reinitializing
the hardware. If the clock rate changed while the device was suspended,
ocores_init() may reject the resulting prescaler. The callback then
returns an error with the clock still enabled, while the controller
itself remains disabled.
Disable and unprepare the clock when ocores_init() fails so the failed
resume path balances the successful clk_prepare_enable() call.
This issue was found by a static analysis checker and confirmed by manual
source review.
Fixes: e961a094af ("i2c: ocores: add common clock support")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://patch.msgid.link/20260813153155.3953577-1-ruoyuw560@gmail.com
This commit is contained in:
@@ -755,7 +755,11 @@ static int ocores_i2c_resume(struct device *dev)
|
||||
rate = clk_get_rate(i2c->clk) / 1000;
|
||||
if (rate)
|
||||
i2c->ip_clock_khz = rate;
|
||||
return ocores_init(dev, i2c);
|
||||
ret = ocores_init(dev, i2c);
|
||||
if (ret)
|
||||
clk_disable_unprepare(i2c->clk);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static DEFINE_NOIRQ_DEV_PM_OPS(ocores_i2c_pm,
|
||||
|
||||
Reference in New Issue
Block a user