mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Li Youhong" <dayou5941@163.com>
To: biju.das.jz@bp.renesas.com, wbg@kernel.org
Cc: linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	cosmin-gabriel.tanislav.xa@renesas.com,
	Li Youhong <liyouhong@kylinos.cn>,
	stable@vger.kernel.org
Subject: [PATCH v3] counter: rz-mtu3-cnt: put runtime PM ref if counter init fails
Date: Sun,  1 Nov 2026 21:07:46 +0800	[thread overview]
Message-ID: <20261101130746.1724364-1-dayou5941@163.com> (raw)

From: Li Youhong <liyouhong@kylinos.cn>

Counter enable takes a runtime PM reference before initialization but
only puts it on disable. Drop the reference if initialization fails.

Fixes: 0be8907359df ("counter: Add Renesas RZ/G2L MTU3a counter driver")
Cc: stable@vger.kernel.org
Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
---
v3:
- Set count_is_enabled from enable after either branch succeeds.
- v2: https://lore.kernel.org/all/20261031142813.2522444-1-dayou5941@163.com/

v2:
- Add Cc: stable@vger.kernel.org.
- v1: https://lore.kernel.org/all/20261008020506.211566-1-dayou5941@163.com/

 drivers/counter/rz-mtu3-cnt.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c
index 7bfb6979193c..e7fe8bf45164 100644
--- a/drivers/counter/rz-mtu3-cnt.c
+++ b/drivers/counter/rz-mtu3-cnt.c
@@ -506,14 +506,17 @@ static int rz_mtu3_count_enable_write(struct counter_device *counter,
 	if (enable) {
 		pm_runtime_get_sync(counter->parent);
 		ret = rz_mtu3_initialize_counter(counter, count->id);
-		if (ret == 0)
-			priv->count_is_enabled[count->id] = true;
+		if (ret < 0) {
+			pm_runtime_put(counter->parent);
+			goto exit;
+		}
 	} else {
 		rz_mtu3_terminate_counter(counter, count->id);
-		priv->count_is_enabled[count->id] = false;
 		pm_runtime_put(counter->parent);
 	}
 
+	priv->count_is_enabled[count->id] = enable;
+
 exit:
 	mutex_unlock(&priv->lock);
 


             reply	other threads:[~2026-11-01 13:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01 13:07 Li Youhong [this message]
2026-11-02  7:40 ` Biju Das
2026-11-02 14:43   ` 李佑鸿 

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=20261101130746.1724364-1-dayou5941@163.com \
    --to=dayou5941@163.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=cosmin-gabriel.tanislav.xa@renesas.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=liyouhong@kylinos.cn \
    --cc=stable@vger.kernel.org \
    --cc=wbg@kernel.org \
    /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®