mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: WenTao Liang <vulab@iscas.ac.cn>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Hans de Goede <hansg@kernel.org>,
	linux-kernel@vger.kernel.org, WenTao Liang <vulab@iscas.ac.cn>
Subject: [PATCH] reset: fix refcount leak in reset_control_bulk_assert()
Date: Thu, 11 Jun 2026 09:57:31 +0800	[thread overview]
Message-ID: <20260611015731.57989-1-vulab@iscas.ac.cn> (raw)

When reset_control_bulk_assert() asserts a batch of reset controls,
it calls reset
Fixes: 0b52297f2288 ("reset: Add support for shared reset controls")
Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
---
 drivers/reset/core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 38e189d04d09..daf9201bc105 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -516,8 +516,15 @@ int reset_control_assert(struct reset_control *rstc)
 		if (WARN_ON(atomic_read(&rstc->deassert_count) == 0))
 			return -EINVAL;
 
-		if (atomic_dec_return(&rstc->deassert_count) != 0)
+		if (atomic_dec_return(&rstc->deassert_count) != 0) {
+			int err = rcdev->ops->assert(rcdev, rstc->id);
+
+			if (err) {
+				atomic_inc(&rstc->deassert_count);
+				return err;
+			}
 			return 0;
+		}
 
 		/*
 		 * Shared reset controls allow the reset line to be in any state
-- 
2.50.1 (Apple Git-155)


             reply	other threads:[~2026-06-11  1:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11  1:57 WenTao Liang [this message]
2026-06-11  8:13 ` 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=20260611015731.57989-1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=hansg@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    /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

all inboxes | Powered by JetHome®