From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA8AA38C2C3 for ; Wed, 24 Jun 2026 08:17:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782289032; cv=none; b=hR+DpFprGOQgTv4AyIq7DT9fYHSPDgTnF1nl6fRujxRRMZDvSF0woLJ34DVs5IN4XiHEn512aLrhpGI0ew7k9wyztDwpKthVQP+/I0kV48CCx9gF2hSSIAwj10OjkCPah4n4l+SpF3wkmCcwvAADSMbuA+XbCaHrnAx9Ikp3JW4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782289032; c=relaxed/simple; bh=jyz1DyVG7HpPxBEvVZr90DObGRcQES4BU+PqnBRSycA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UWFZWTErIyl+9GELV8igYf+q/htQhZjQRt+6MDND/MnbGSSuY07eW4YtYUQ7ft8yPVys5ZBNtcZvScTdlIx1ESya83UkpRDv00BXfscKB2SnkNBPcwKEhnZuqQL5i1kRv8nD2tv+cqKPVNPgMDPbHFhhP+fG6DzUL7G7K0AqRJY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=qFx8NW+k; arc=none smtp.client-ip=209.85.215.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qFx8NW+k" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-c88d1d4543fso987870a12.0 for ; Wed, 24 Jun 2026 01:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782289031; x=1782893831; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=36jF0aae/2qf/mqPeDqHORRtGgqdr7FBWT7b1LCQhJc=; b=qFx8NW+k9zLv5n+g7bFH840queuFNmLec8hTW4ji4fbyiD/w4kA8VaDw2lc3h/OlFr meFVuOrPDJvINfrablxwZGe4tUHRi8+871zNLGI19xM3t8EbJX8SI6URxPJXD67LnwZL mpyR1XdWC56/gM1+hcW4dwP55OBhqKscJjZYlkIzBdPFF0gEXnZQ6mX/PPbrdioQ5CIr mWoKSzzIJUk9DVOJsFXxmD2ajNEjufhHdQibs40QE90Wq6EunsOMg+SChYC61fstcKab Gk4/p6ugULmp3tkarjigmZEngiVnKNizdr6gJH20/g0doloJE7UwYLKUJmyWkvIFkl7P SZHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782289031; x=1782893831; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=36jF0aae/2qf/mqPeDqHORRtGgqdr7FBWT7b1LCQhJc=; b=aXFrEJ2FVlOPE9z23RcIcILw7FOFyUKxHrZK/7bGV1YnGJSVaeQDI1cUyKTCqCHDft LJ9wk+Cq9qqJxAHkWup3J9Zhhbo1/T1+euxEEHo23ihYGw+Ym+hcoi1IfZWI9mVHIaDm YeMRrcu1Dg4YwhVD8HVTJjNLH8NJFlStJdkvt50k1YhajawCp1qTaMd4fT1H7zuyp5XK LVBFO9xb9R7jyCD4zdCFDgma3XZQYh/gT72CYDulIpQbFemepVzZs6ad36F2QXawy7mN 30QIBHbhwi2rJSSIEYwbvTGqPsUUOlJVy387go44lwDH0kaiFywxYGQ7TygQm1Pd8fPt lOrA== X-Forwarded-Encrypted: i=1; AHgh+RodDvXfl4QBZivUWO8hANMsSJoSDQVMmKQ27hw6oMOtuzBf+cjLBpmzgMSz9n5oJMT2F9G/zvbwN2gykzE=@vger.kernel.org X-Gm-Message-State: AOJu0Yyovmd5rZvSyvOUzK5CDScY2QSUzKQI2UintT5Oq6u5A/IM810r cTZe9uzNFKesRSrLvKcXN2CYQIwl15tPhQ94mbyWKnoERyKuHOxKyd8= X-Gm-Gg: AfdE7cnzUolJlE3lFPiHyKLT2vWjPr4VKwPI1KmFsCxGAUalbuB1GfpkuHaHuv7VzlO ImRPGNU0pDDQPNcRY5efZbRpEv0bW8fAmvC0u62+XakACGLSKiWbDejKhDkufZYnGuY6J4L2/5D hCbUYNFV3RJmh1I/fUIrD4e1TTvdotIAtL1mWIwIjzbj56Dk5ljLSH77Ako4td1Y623KhjwSWam 2pFMGJsAEsic9EDNtmvlujVlGZoRXgv35o/vmD9GuSAL4stmps9YmEuwml99gfVrkYihT6l1Qe2 iqtMXJhu3KIq8sPe/Fi/c7M1AJEr+5NhciVoSebOuh9MVLtZXVIIwZB7Y4ukwozA1SJ6elQMl7t 8I+Gx6F6yoSaZcoYA4sGDDSmSvvyPmENwAIeaY7bg06W6Y4NFG2xEejA5ut6pmaSONYXQVEaSNv lLyoWm7QmSJsQ7n75WNqjvU54hSZM64gngi7m9pYkmeXCFKY7bYfhHKzQwGKCoUdkL X-Received: by 2002:a17:903:8c5:b0:2bd:3c21:a053 with SMTP id d9443c01a7336-2c7c3ff8e32mr60401005ad.24.1782289030882; Wed, 24 Jun 2026 01:17:10 -0700 (PDT) Received: from localhost.localdomain ([14.5.152.27]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c7436f7de7sm121836085ad.32.2026.06.24.01.17.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 24 Jun 2026 01:17:10 -0700 (PDT) From: Myeonghun Pak To: Sean Wang , Vinod Koul , Frank Li , Matthias Brugger , AngeloGioacchino Del Regno Cc: dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Myeonghun Pak , Ijae Kim Subject: [PATCH] dmaengine: mediatek: hsdma: fix runtime PM leak on init failure Date: Wed, 24 Jun 2026 17:16:38 +0900 Message-ID: <20260624081701.19358-1-mhun512@gmail.com> X-Mailer: git-send-email 2.47.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, runtime PM is left enabled with the usage count held. Use pm_runtime_resume_and_get() so resume failures do not leak the usage count, and unwind runtime PM when clk_prepare_enable() fails. 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 --- drivers/dma/mediatek/mtk-hsdma.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/dma/mediatek/mtk-hsdma.c b/drivers/dma/mediatek/mtk-hsdma.c index a43412ff5e..987e5274fc 100644 --- a/drivers/dma/mediatek/mtk-hsdma.c +++ b/drivers/dma/mediatek/mtk-hsdma.c @@ -849,16 +849,25 @@ 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 = pm_runtime_resume_and_get(hsdma2dev(hsdma)); + if (err < 0) + goto err_disable_pm; 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)); +err_disable_pm: + pm_runtime_disable(hsdma2dev(hsdma)); + + return err; } static int mtk_hsdma_hw_deinit(struct mtk_hsdma_device *hsdma) @@ -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.47.1