Linux-Amlogic Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "WenTao Liang" <vulab@iscas.ac.cn>
Cc: linux-amlogic@lists.infradead.org, neil.armstrong@linaro.org
Subject: Re: [PATCH] rtc: meson: fix refcount leak in meson_rtc_get_bus
Date: Thu, 11 Jun 2026 03:47:54 +0000	[thread overview]
Message-ID: <20260611034755.3074B1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260611034040.59682-1-vulab@iscas.ac.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Bogus fix attempting to fix a non-existent refcount leak, which violates the reset API contract and introduces a potential counter underflow.
--

commit dec7a1c708a5b28d1344bf6fb038df54d6001df3
Author: WenTao Liang <vulab@iscas.ac.cn>
rtc: meson: fix refcount leak in meson_rtc_get_bus

This commit adds calls to reset_control_rearm() in both the error and success
paths of meson_rtc_get_bus() after triggering a reset. The intention is to
prevent a triggered_count leak on shared reset controls.

> diff --git a/drivers/rtc/rtc-meson.c b/drivers/rtc/rtc-meson.c
> index 21eceb9e2e134..3c45cd761a15a 100644
> --- a/drivers/rtc/rtc-meson.c
> +++ b/drivers/rtc/rtc-meson.c
> @@ -146,8 +146,12 @@ static int meson_rtc_get_bus(struct meson_rtc *rtc)
>  		dev_warn(rtc->dev, "failed to get bus, resetting RTC\n");
>  
>  		ret = reset_control_reset(rtc->reset);
> -		if (ret)
> +		if (ret) {
> +			reset_control_rearm(rtc->reset);

[Severity: Medium]
Is this fix applicable to this driver's reset control?

The reset control rtc->reset is acquired as an exclusive control using
devm_reset_control_get(). Exclusive controls do not track triggered_count,
so calling reset_control_rearm() is a no-op in this context, meaning there
was no leak to fix.

Additionally, if this were a shared reset control, would calling
reset_control_rearm() on the error path cause a counter underflow?

The reset core already handles the rollback internally by decrementing
triggered_count if the underlying reset fails. Adding a manual
reset_control_rearm() here on failure would decrement it a second time,
which could trigger a WARN_ON() for dropping below zero.

> +			return ret;
> +		}
> +
> +		reset_control_rearm(rtc->reset);
>  	}
>  
>  	dev_err(rtc->dev, "bus is not ready\n");

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260611034040.59682-1-vulab@iscas.ac.cn?part=1

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply	other threads:[~2026-06-11  3:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11  3:40 [PATCH] rtc: meson: fix refcount leak in meson_rtc_get_bus WenTao Liang
2026-06-11  3:47 ` sashiko-bot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-06-11  3:56 WenTao Liang
2026-06-11  4:03 ` sashiko-bot
2026-06-11  8:08 ` Philipp Zabel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260611034755.3074B1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vulab@iscas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox