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=1795047954; b=cieaBK/hPbaSgnzB7XUqYnxiY8yAJPRgesDT1HXw/AS3nEbxSoyBscrw2kFHsE9btsWX sWaUoxsXLFnGRMs75dcwAtN7AYDg2Y+kOH7VAeNYWg4+ZLxOjFzJiuI78kzVSUiVfnfSA IBc3XKBadkodfrAR0lZ3djgZwU/4A/PJLkxF+T9CtnHTqvHcAFP0aTYRRh/8NrJnldL7j GdFS4t2iXD0TcxLxH4+a+smBN9HS4L77/CdRSaKGJHO+Q054+KK2qhlZyJS+4PsItD7Dt AYopHxEswo2M+GVtoPrRmzjNdcqnwNzP85PD3LaYK9b4xoDrXCrNHFSqzKT+KZITgpQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795047954; 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=nRFvSYbyCUTCm36JXgFPqoN3li7t08QyOjiUALlWxk0=; b=ohYsB2kpCU4TWtNNO93iMTBUBMfmt5TfUoppIS8b7sFeeLrf+wZPqtsWY2sAYwKQ3Ugg RURQvf4XAWG3CwU4PkZjffbtR/TrNU5hd7rcv76KIlOAMzNNKS51I6ycsCo4+sXiMRnzX it7BY2WSew9ZGkyXlwPFJ77B90KfxbEjtjfWgrVBYqItV7XPOCBM21n1S/aevrbZrXID6 TXvumjuwuaPJHjlI2Y4aKmajhGy8GDhdabgVuAawkgRXGOO/8lSPAllgE8t0wsqjRJGxX f0yMEBG87HthHNl4P7WK5RKsSaSSZln9111Y1w/PTrXpBwUmpm1GmcbNUNmbgnkDjzA== 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=1B9iQCWk; 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 E835E606A320; Thu, 19 Nov 2026 00:25:53 +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=1B9iQCWk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17DCA1F000C4; Thu, 19 Nov 2026 00:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795047953; bh=nRFvSYbyCUTCm36JXgFPqoN3li7t08QyOjiUALlWxk0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1B9iQCWkJxOjkXUdFPgigcmnhIYNe5sU4lcNmczs5q2NTgvP88mJFtWHCxFXn7j7V OpZWc6aX0u6GhkyVuP73f7FE8SWhhsIcFm8hTKpf9qRUfC2vLaYH25wiO5TcpM83Ho H7ycOlFr9vVCit10KeFa/aU5cHEAnFXgI+sleFvg= 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.1 1823/2857] dmaengine: mediatek: hsdma: fix runtime PM leak on init failure Date: Wed, 18 Nov 2026 15:47:37 +0100 Message-ID: <20261118150306.904605321@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150201.293410965@linuxfoundation.org> References: <20261118150201.293410965@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.1-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 f7717c44b8879..05526e9bf1b7f 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; } @@ -986,7 +995,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, @@ -994,7 +1005,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); @@ -1003,8 +1014,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