i2c: riic: fix refcount leak in riic_i2c_resume_noirq()
Subsystems (3)
PATCH 1/1 i2c: riic: fix refcount leak in riic_i2c_resume_noirq()
When riic_i2c_resume_noirq() is called, it deasserts the reset using reset_control_deassert(), which for shared resets increments a reference count. If pm_runtime_force_resume() then fails, the function returns without calling reset_control_assert() to decrement the count. This leaves the reset deasserted and the reference count unbalanced, which can prevent other users of the shared reset from properly asserting it later.
Fix the leak by calling reset_control_assert() on the error handling path for a failed pm_runtime_force_resume().
--- drivers/i2c/busses/i2c-riic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-riic.c +3 -1
@@ -725,8 +725,10 @@ static int riic_i2c_resume_noirq(struct device *dev)return ret; ret =pm_runtime_force_resume (dev); -if (ret) +if (ret) { +reset_control_assert (riic->rstc);return ret; + } ret =riic_init_hw (riic);if (ret) {
Signature · 1 line
2.34.1
Quoted 8 lines · Wentao Liang
When
riic_i2c_resume_noirq()is called, it deasserts the reset usingreset_control_deassert(), which for shared resets increments a reference count. Ifpm_runtime_force_resume()then fails, the function returns without callingreset_control_assert()to decrement the count. This leaves the reset deasserted and the reference count unbalanced, which can prevent other users of the shared reset from properly asserting it later.
Quoted 6 lines
Fix the leak by calling
reset_control_assert()on the error handling path for a failedpm_runtime_force_resume().Fixes e383f0961422 ("i2c: riic: Move suspend handling to NOIRQ phase")Signed-off-by Wentao Liang <[email protected]>
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Hi Wentao,
Quoted 8 lines · Wentao Liang
When
riic_i2c_resume_noirq()is called, it deasserts the reset usingreset_control_deassert(), which for shared resets increments a reference count. Ifpm_runtime_force_resume()then fails, the function returns without callingreset_control_assert()to decrement the count. This leaves the reset deasserted and the reference count unbalanced, which can prevent other users of the shared reset from properly asserting it later.
Quoted 6 lines
Fix the leak by calling
reset_control_assert()on the error handling path for a failedpm_runtime_force_resume().Fixes e383f0961422 ("i2c: riic: Move suspend handling to NOIRQ phase")Signed-off-by Wentao Liang <[email protected]>
merged to i2c/i2c-host-fixes.
Thanks,
Andi