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=1795029365; b=ska8PlHZ9RXgSBFCcUZwA9UbcYqkC470y9KGrnl2DEcOe9PLasISRzxB7S70zQPTkwPI o4tLnBgenOXVaVLcuDSUpsVC913poODkhe26Ny6h402g+8fKJ4rWfYz4a5U9u+r8jH2aE 5VjmrB14tzmxBNSDo31MThQf7SpaigHStvMhGayJsuNspMDHOkgsQfN+Jc9pOUBpnsK+i lG1ssM8ac7O1th+5jLkahnTUboBNWTL82XHxb0QXiR2wGReyvPZIQ3Dam1Gg92G8CWaE4 eslcLGD4t/jiteYsZQeKEP5Cx/CtdTiPSlcNHeTgfxp8otEloIFwJZyqcE9WXEdGdzw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795029365; 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=f6MBWbIdfplJ1W2cbCNPdIcFchx2k3QlKXg3qPNhAtY=; b=JKrC/uImECmSqpOuJcxk9RXSdvPY8CBZX8rCCBgSha6YVOOUe2GllKF5q6aSCoL4zPMg UBo+A2v7MN3W16C/qHRnIev98QvKqamLYLRE8HJ3nwJcXZg6rdYIk6KRpTNCEAXjofyCW A4N+nd5ubp6prNX6+ItXBLHUBvL0a/xXjoVUBLq+yEO4q4mAM5OmDnUROryVp2aP4JaVO auYI6f40y6qjOua9f6uJuFpOx9JF3VrQKXzWqw/oItdTzOhEYkjFyUXgjkdM5eOuOtMat 8SMLuWBGOCg3HB4CVTfDrkqOhUVRupzgdw583MzT9MrmqwPe/e0OYZY216M0TrZx/aw== 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=ZXOPAI2O; 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 3FB06606A334; Wed, 18 Nov 2026 19:16:04 +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=ZXOPAI2O Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46CD81F000C6; Wed, 18 Nov 2026 19:16:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795029364; bh=f6MBWbIdfplJ1W2cbCNPdIcFchx2k3QlKXg3qPNhAtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZXOPAI2OrvnAeHLr7w/huwxPG/bYD9tgwkoPeno38x0E/n5p8WfLE8yR1JBCDnFXL NLi/DX7QyfJAZgF1SEJapZiqBTy53sU00GfsODtD3V1/3iwQCX/S3s3o2vgkhoNFrZ stDDR5bO0UqscffohqxXqmBs2Ff1Ovx7a+oHYdro= 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.12 0274/1756] dmaengine: mediatek: hsdma: fix runtime PM leak on init failure Date: Wed, 18 Nov 2026 15:40:01 +0100 Message-ID: <20261118150019.331613548@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150007.957976754@linuxfoundation.org> References: <20261118150007.957976754@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.12-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 58c7961ab9ad1..abbad59e0f958 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