From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795023358; b=p1ghxxQMUV54gUj1gtj5erWt7xmCH+OCB04UG0F9dDEKV9emKj3sA4iArkII4qzy9PYy oANR335i2cYlHaVBB5SL3rKw8SEncqo89/7z+kf3GOOluW10eGi8kxY+P7dgjUzzY21Dl miQssbRBjiTxcaRoQociLOuWWbMh7i4JeDRX415d1IqAY8BXi7/2I/bBUxPmXsYDkjaRF Ze1FK6jQ/fT2H+/rZ4FJaotTcdtx8J1VaVSXVqd2ub0zu6Yf/pbuOGfhyZ+ZYVo4M0utW iBzPBS4gQyQt6Do15nH2ypCvA4HsxpOWcPXf5fD0RZMUY31k/kmH1HE2xV/Eaw2V52w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795023358; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=DJ1GC+Gcxb9WwUNRDsRUPXAeY1qVUtKq5dAsfJxl2uY=; b=vWoEKShy8WXdkTY5s+LuucpgMIYZ6aYfzGewB/1d45hgpi51ade+2mfpHNT7uKn6AiTH b31MRZO279PEIWwqfX5Ak+82cNSmSr4w4DmbibTn1o7GwAj/7edjOrlBmZkF2eXhJJW2a mOKVpY0v2c+l447rxLjRS4+AoybcwJM68tPvyc6uXJP11tX0R1R7jeXezWPLNgJA+fILA A1w4NHNizPKIf/rl/obZrSWBDbqZ8yF7tQ4TGyFG+7EX4ULvlE++fAScektQdJ0XN46Wz 95Gwz3aWYwymJ+qLpoymfHsSvMKIbLa/88XPK6WwsJO8Nfj4VUY1kmDV8YnTJ12YB1w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=twNjrDt8; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D98F3606CA45; Wed, 18 Nov 2026 17:35:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=twNjrDt8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 341151F000C9; Wed, 18 Nov 2026 17:35:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795023358; bh=DJ1GC+Gcxb9WwUNRDsRUPXAeY1qVUtKq5dAsfJxl2uY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=twNjrDt8i8AIMUbWDKgcImDDCQViQm4dENdZ2IL8C0hPRGiutCSWTeeMcgZri6glv Q29G4SCnVopyBxvLC1BktrbsGXeM8AVrgNg/OsIOcvZ5cRgGFNBLv6sGdUO/37b0pj xDW9SnpytcLfxCn37uhZ1M0LBYXVfgOD7z82doH0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ijae Kim , Myeonghun Pak , Frank Li , Vinod Koul , Sasha Levin Subject: [PATCH 6.18 0298/2151] dmaengine: mediatek: hsdma: fix runtime PM leak on init failure Date: Wed, 18 Nov 2026 15:33:53 +0100 Message-ID: <20261118150132.770172394@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150121.603863898@linuxfoundation.org> References: <20261118150121.603863898@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Myeonghun Pak [ Upstream commit f10d96b1c549a2f43506e9bf847196839808b8dc ] mtk_hsdma_hw_init() enables runtime PM and gets a runtime PM reference before enabling the HSDMA clock. It currently ignores failures from pm_runtime_get_sync(); if runtime resume fails, the usage count remains held. If clk_prepare_enable() then fails, the usage count remains held. Use devm_pm_runtime_enable() to manage runtime PM enablement, and use pm_runtime_resume_and_get() so resume failures do not leak the usage count. If clk_prepare_enable() fails after a successful runtime resume, drop the runtime PM reference before returning. The probe path also ignores the return value from mtk_hsdma_hw_init(), so a failed hardware init can continue as a successful probe. Propagate mtk_hsdma_hw_init() failures from probe, while keeping a separate unwind label so mtk_hsdma_hw_deinit() is only called after hardware init succeeds. Fixes: 548c4597e984 ("dmaengine: mediatek: Add MediaTek High-Speed DMA controller for MT7622 and MT7623 SoC") Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak Reviewed-by: Frank Li Link: https://patch.msgid.link/20260804153924.49627-1-mhun512@gmail.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/mediatek/mtk-hsdma.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/dma/mediatek/mtk-hsdma.c b/drivers/dma/mediatek/mtk-hsdma.c index fa77bb24a4307..86fa911c5ac53 100644 --- a/drivers/dma/mediatek/mtk-hsdma.c +++ b/drivers/dma/mediatek/mtk-hsdma.c @@ -848,17 +848,27 @@ static int mtk_hsdma_hw_init(struct mtk_hsdma_device *hsdma) { int err; - pm_runtime_enable(hsdma2dev(hsdma)); - pm_runtime_get_sync(hsdma2dev(hsdma)); + err = devm_pm_runtime_enable(hsdma2dev(hsdma)); + if (err) + return err; + + err = pm_runtime_resume_and_get(hsdma2dev(hsdma)); + if (err < 0) + return err; err = clk_prepare_enable(hsdma->clk); if (err) - return err; + goto err_put_pm; mtk_dma_write(hsdma, MTK_HSDMA_INT_ENABLE, 0); mtk_dma_write(hsdma, MTK_HSDMA_GLO, MTK_HSDMA_GLO_DEFAULT); return 0; + +err_put_pm: + pm_runtime_put_sync(hsdma2dev(hsdma)); + + return err; } static int mtk_hsdma_hw_deinit(struct mtk_hsdma_device *hsdma) @@ -868,7 +878,6 @@ static int mtk_hsdma_hw_deinit(struct mtk_hsdma_device *hsdma) clk_disable_unprepare(hsdma->clk); pm_runtime_put_sync(hsdma2dev(hsdma)); - pm_runtime_disable(hsdma2dev(hsdma)); return 0; } @@ -983,7 +992,9 @@ static int mtk_hsdma_probe(struct platform_device *pdev) goto err_unregister; } - mtk_hsdma_hw_init(hsdma); + err = mtk_hsdma_hw_init(hsdma); + if (err) + goto err_free; err = devm_request_irq(&pdev->dev, hsdma->irq, mtk_hsdma_irq, 0, @@ -991,7 +1002,7 @@ static int mtk_hsdma_probe(struct platform_device *pdev) if (err) { dev_err(&pdev->dev, "request_irq failed with err %d\n", err); - goto err_free; + goto err_deinit; } platform_set_drvdata(pdev, hsdma); @@ -1000,8 +1011,9 @@ static int mtk_hsdma_probe(struct platform_device *pdev) return 0; -err_free: +err_deinit: mtk_hsdma_hw_deinit(hsdma); +err_free: of_dma_controller_free(pdev->dev.of_node); err_unregister: dma_async_device_unregister(dd); -- 2.53.0