mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] i2c: riic: fix refcount leak in riic_i2c_resume_noirq()
@ 2026-06-08  7:11 Wentao Liang
  2026-06-08  7:41 ` Geert Uytterhoeven
  2026-06-08 15:37 ` Andi Shyti
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-06-08  7:11 UTC (permalink / raw)
  To: chris.brandt, andi.shyti
  Cc: linux-renesas-soc, linux-i2c, linux-kernel, Wentao Liang, stable

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().

Cc: stable@vger.kernel.org
Fixes: e383f0961422 ("i2c: riic: Move suspend handling to NOIRQ phase")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/i2c/busses/i2c-riic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
index 9e3595b3623e..6d2ebf67dd62 100644
--- a/drivers/i2c/busses/i2c-riic.c
+++ b/drivers/i2c/busses/i2c-riic.c
@@ -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) {
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: riic: fix refcount leak in riic_i2c_resume_noirq()
  2026-06-08  7:11 [PATCH] i2c: riic: fix refcount leak in riic_i2c_resume_noirq() Wentao Liang
@ 2026-06-08  7:41 ` Geert Uytterhoeven
  2026-06-08 15:37 ` Andi Shyti
  1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2026-06-08  7:41 UTC (permalink / raw)
  To: Wentao Liang
  Cc: chris.brandt, andi.shyti, linux-renesas-soc, linux-i2c,
	linux-kernel, stable

On Mon, 8 Jun 2026 at 09:13, Wentao Liang <vulab@iscas.ac.cn> wrote:
> 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().
>
> Cc: stable@vger.kernel.org
> Fixes: e383f0961422 ("i2c: riic: Move suspend handling to NOIRQ phase")
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: riic: fix refcount leak in riic_i2c_resume_noirq()
  2026-06-08  7:11 [PATCH] i2c: riic: fix refcount leak in riic_i2c_resume_noirq() Wentao Liang
  2026-06-08  7:41 ` Geert Uytterhoeven
@ 2026-06-08 15:37 ` Andi Shyti
  1 sibling, 0 replies; 3+ messages in thread
From: Andi Shyti @ 2026-06-08 15:37 UTC (permalink / raw)
  To: Wentao Liang
  Cc: chris.brandt, linux-renesas-soc, linux-i2c, linux-kernel, stable

Hi Wentao,

On Mon, Jun 08, 2026 at 07:11:23AM +0000, Wentao Liang wrote:
> 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().
> 
> Cc: stable@vger.kernel.org
> Fixes: e383f0961422 ("i2c: riic: Move suspend handling to NOIRQ phase")
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

merged to i2c/i2c-host-fixes.

Thanks,
Andi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-08 15:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-08  7:11 [PATCH] i2c: riic: fix refcount leak in riic_i2c_resume_noirq() Wentao Liang
2026-06-08  7:41 ` Geert Uytterhoeven
2026-06-08 15:37 ` Andi Shyti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®