The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: manushprajwal <manushprajwal555@gmail.com>
To: jassisinghbrar@gmail.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] mailbox: mtk-cmdq: fix runtime PM usage counter leak in cmdq_mbox_flush
Date: Sun, 23 Aug 2026 16:53:21 +0530	[thread overview]
Message-ID: <20260823112321.2039-1-manushprajwal555@gmail.com> (raw)

cmdq_mbox_flush() calls pm_runtime_get_sync() and returns its error
code directly on failure. Per Documentation/power/runtime_pm.rst,
pm_runtime_get_sync() does not drop the usage counter on error, so the
caller is expected to release the reference itself. The early return
here skips that, leaking a runtime PM usage count on cmdq->mbox.dev on
every failed resume.

Fix it by calling pm_runtime_put_noidle() before returning, matching
the pattern used by other pm_runtime_get_sync() callers in the same
subsystem (e.g. drivers/i2c/busses/i2c-tegra.c, drivers/gnss/sirf.c).

Signed-off-by: manushprajwal <manushprajwal555@gmail.com>
---
 drivers/mailbox/mtk-cmdq-mailbox.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index e523c84b4..2010aadbc 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -565,8 +565,10 @@ static int cmdq_mbox_flush(struct mbox_chan *chan, unsigned long timeout)
 	int ret;
 
 	ret = pm_runtime_get_sync(cmdq->mbox.dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_noidle(cmdq->mbox.dev);
 		return ret;
+	}
 
 	spin_lock_irqsave(&thread->chan->lock, flags);
 	if (list_empty(&thread->task_busy_list))
-- 
2.46.2.windows.1


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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-23 11:23 manushprajwal [this message]
2026-08-24  5:43 ` [PATCH] mailbox: mtk-cmdq: fix runtime PM usage counter leak in cmdq_mbox_flush Markus Elfring

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=20260823112321.2039-1-manushprajwal555@gmail.com \
    --to=manushprajwal555@gmail.com \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-kernel@vger.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