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=1795060399; b=Ji1ZhOBz/ThKcR/I4FTLv7KRoVBZprtSIdNRnsYjKyiHUES+AirtB8JhaAjxxlA24FPe pffGjCfG7dJhv/DVXBtkiw2lcZONUL7jo7mStYxbAQazxDieE+BIOix2lYC4rBiYDy+Da IUxp/ETm1qYOh2JX2daVMlGMdS+iWxSOA4JTGKLJuMLPA8XFgd6L41rTIH1AP4Z6I+l+s 21ezQxgqeYe2R6lzrLTtwSzIOkRj0RtDEoF1pFqYWRcld6tLl4/NPNZB/fUmiQodIPYva XRd+nv8JMIKjdweu3+0TWN8xfRj1rIcooyLZKrqpKB6eOuYZ2k8CUX/RM+pFrUGittw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795060399; 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=vHNIui7vfjhnLj5EMO+4uwAr5M+KDU0YRu5Fr34PT/M=; b=Y/rX9mE1mAa1btxpBLFyUyTOPOtoPEW07nhT7+eWgobTuBe8EkCr7FH0bEcSjB4n8neh F4THhe7VV7xbiE8pjRSlKdYGqciAmp0xsiQXjJCXtsy9iRLI4kejG6aBowqNUb5RTPNlr BEvyPBdlDU8B+S5zo+To0vRFMGBmw8roAZvHPuKzDtWrL02hHrPnI1BDNG6XvXcRTITNo /ZwgWJzyq2Ii3uNnEKDKb88aFLc6t66S04s3KYM3woEMpA1lnRgG8feQDkumRIoTKDNyL YrsxdneCeoFL0z7bgP6d5bdjCgkipjb84NMlk4EWp3bIjbNRmaDZYlZy7alkth9SNRA== 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=cx6lQir3; 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 67A97606A325; Thu, 19 Nov 2026 03:53:19 +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=cx6lQir3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5F961F000C4; Thu, 19 Nov 2026 03:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795060399; bh=vHNIui7vfjhnLj5EMO+4uwAr5M+KDU0YRu5Fr34PT/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cx6lQir3TtAuniAtnQ+pN5wbFTFpD7vybfcdzebMtwXo5zCNNos3e0OcFfsN3DP43 bkn/skzc7JprHWs0+lcw//v/Eqnw3yrncQpgXCbqzz+Ebnbn7R8Vuhb95cI5iygfsp mo030E/Kk47wFMxGI6vAx1tig1P+lI7kZKZfVXZ4= 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 5.10 1184/1848] dmaengine: mediatek: hsdma: fix runtime PM leak on init failure Date: Wed, 18 Nov 2026 15:53:42 +0100 Message-ID: <20261118150009.100340614@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118145911.150052362@linuxfoundation.org> References: <20261118145911.150052362@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 5.10-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 6ad8afbb95f2b..1a65302219189 100644 --- a/drivers/dma/mediatek/mtk-hsdma.c +++ b/drivers/dma/mediatek/mtk-hsdma.c @@ -849,17 +849,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) @@ -869,7 +879,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; } @@ -989,7 +998,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, @@ -997,7 +1008,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); @@ -1006,8 +1017,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