Skip to contentSkip to conversation

mailbox: mtk-cmdq: fix runtime PM usage counter leak in cmdq_mbox_flush

PATCH Superseded Manush Prajwal 1 participant 1 message Aug 24

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mailbox: mtk-cmdq: fix runtime PM usage counter leak in cmdq_mbox_flush

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 switching to pm_runtime_resume_and_get(), which performs the get-and-put internally on failure so the caller doesn't need a manual pm_runtime_put_noidle(), per Markus Elfring's review of v1.

---
v2: Use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
plus a manual pm_runtime_put_noidle() on the error path, per Markus Elfring's review.

 drivers/mailbox/mtk-cmdq-mailbox.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mailbox/mtk-cmdq-mailbox.c +1 -2
index e523c84b4..b1a2c3d4e 100644
@@ -565,7 +565,7 @@ static int cmdq_mbox_flush(struct mbox_chan *chan, unsigned long timeout)
 	int ret;
 
-	ret = pm_runtime_get_sync(cmdq->mbox.dev);
+	ret = pm_runtime_resume_and_get(cmdq->mbox.dev);
 	if (ret < 0)
 		return ret;
 
--

2.46.2.windows.1