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 04:03:17 +0000	[thread overview]
Message-ID: <20260611040318.239AE1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260611035605.59906-1-vulab@iscas.ac.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch attempts to fix a non-existent refcount leak by adding reset_control_rearm() to an exclusive reset control (where it is a no-op). Furthermore, if the reset control were actually shared, adding reset_control_rearm() to the error path would cause a double-decrement underflow bug.
--

commit c52dd99142fd976704b680f05d5ba9c353703d91
Author: WenTao Liang <vulab@iscas.ac.cn>

rtc: meson: fix refcount leak in meson_rtc_get_bus

This commit attempts to fix a refcount leak by adding reset_control_rearm()
to both the error and success paths of reset_control_reset() in
meson_rtc_get_bus().

> 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 reset control actually shared? The rtc->reset appears to be acquired
as an exclusive reset control, where reset_control_rearm() is documented to
be a no-op and triggered_count is not used.

Also, if this were a shared reset control, would calling
reset_control_rearm() on the error path cause a double-decrement underflow?

The reset core framework automatically rolls back the triggered_count
increment if the underlying hardware reset fails. Manually calling
reset_control_rearm() after a failure might drop the counter below zero
and trigger a warning.

>  			return ret;
> +		}
> +
> +		reset_control_rearm(rtc->reset);
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260611035605.59906-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  4:03 UTC|newest]

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

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=20260611040318.239AE1F00893@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