dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Vinod Koul <vkoul@kernel.org>
Cc: "Ludovic Desroches" <ludovic.desroches@microchip.com>,
	"Viresh Kumar" <vireshk@kernel.org>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Vinicius Costa Gomes" <vinicius.gomes@intel.com>,
	"Dave Jiang" <dave.jiang@intel.com>,
	"Vladimir Zapolskiy" <vz@mleia.com>,
	"Piotr Wojtaszczyk" <piotr.wojtaszczyk@timesys.com>,
	"Amélie Delaunay" <amelie.delaunay@foss.st.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Peter Ujfalusi" <peter.ujfalusi@gmail.com>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Johan Hovold" <johan@kernel.org>,
	stable@vger.kernel.org,
	"Fabrizio Castro" <fabrizio.castro.jz@renesas.com>
Subject: [PATCH 08/15] dmaengine: sh: rz-dmac: fix device leak on probe failure
Date: Mon, 17 Nov 2025 17:12:51 +0100	[thread overview]
Message-ID: <20251117161258.10679-10-johan@kernel.org> (raw)
In-Reply-To: <20251117161258.10679-1-johan@kernel.org>

Make sure to drop the reference taken when looking up the ICU device
during probe also on probe failures (e.g. probe deferral).

Fixes: 7de873201c44 ("dmaengine: sh: rz-dmac: Add RZ/V2H(P) support")
Cc: stable@vger.kernel.org	# 6.16
Cc: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/dma/sh/rz-dmac.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 1f687b08d6b8..38137e8d80b9 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -854,6 +854,13 @@ static int rz_dmac_chan_probe(struct rz_dmac *dmac,
 	return 0;
 }
 
+static void rz_dmac_put_device(void *_dev)
+{
+	struct device *dev = _dev;
+
+	put_device(dev);
+}
+
 static int rz_dmac_parse_of_icu(struct device *dev, struct rz_dmac *dmac)
 {
 	struct device_node *np = dev->of_node;
@@ -876,6 +883,10 @@ static int rz_dmac_parse_of_icu(struct device *dev, struct rz_dmac *dmac)
 		return -ENODEV;
 	}
 
+	ret = devm_add_action_or_reset(dev, rz_dmac_put_device, &dmac->icu.pdev->dev);
+	if (ret)
+		return ret;
+
 	dmac_index = args.args[0];
 	if (dmac_index > RZV2H_MAX_DMAC_INDEX) {
 		dev_err(dev, "DMAC index %u invalid.\n", dmac_index);
@@ -1055,8 +1066,6 @@ static void rz_dmac_remove(struct platform_device *pdev)
 	reset_control_assert(dmac->rstc);
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-
-	platform_device_put(dmac->icu.pdev);
 }
 
 static const struct of_device_id of_rz_dmac_match[] = {
-- 
2.51.0


  parent reply	other threads:[~2025-11-17 16:13 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17 16:12 [PATCH 00/15] dmaengine: fix device leaks Johan Hovold
2025-11-17 16:12 ` [PATCH 01/15] dmaengine: at_hdmac: fix device leak on of_dma_xlate() Johan Hovold
2025-11-17 17:08   ` Andy Shevchenko
2025-11-18  9:29     ` Johan Hovold
2025-11-17 16:12 ` [PATCH] dmaengine: ti: k3-udma: enable compile testing Johan Hovold
2025-11-17 16:14   ` Johan Hovold
2025-11-17 16:12 ` [PATCH 02/15] dmaengine: bcm-sba-raid: fix device leak on probe Johan Hovold
2025-11-17 16:12 ` [PATCH 03/15] dmaengine: cv1800b-dmamux: fix device leak on route allocation Johan Hovold
2025-11-17 16:12 ` [PATCH 04/15] dmaengine: dw: dmamux: fix OF node leak on route allocation failure Johan Hovold
2025-11-17 17:05   ` Andy Shevchenko
2025-11-18  9:13     ` Miquel Raynal
2025-11-18  9:21     ` Johan Hovold
2025-11-17 16:12 ` [PATCH 05/15] dmaengine: idxd: fix device leaks on compat bind and unbind Johan Hovold
2025-11-17 16:18   ` Dave Jiang
2025-11-17 16:21     ` Johan Hovold
2025-11-17 16:12 ` [PATCH 06/15] dmaengine: lpc18xx-dmamux: fix device leak on route allocation Johan Hovold
2025-11-17 19:24   ` Vladimir Zapolskiy
2025-11-18  9:30     ` Johan Hovold
2025-11-17 16:12 ` [PATCH 07/15] dmaengine: lpc32xx-dmamux: " Johan Hovold
2025-11-17 19:27   ` Vladimir Zapolskiy
2025-11-17 16:12 ` Johan Hovold [this message]
2025-11-18 13:49   ` [PATCH 08/15] dmaengine: sh: rz-dmac: fix device leak on probe failure Fabrizio Castro
2025-11-17 16:12 ` [PATCH 09/15] dmaengine: stm32: dmamux: fix device leak on route allocation Johan Hovold
2025-11-18  8:11   ` Amelie Delaunay
2025-11-18  9:31     ` Johan Hovold
2025-11-17 16:12 ` [PATCH 10/15] dmaengine: stm32: dmamux: fix OF node leak on route allocation failure Johan Hovold
2025-11-18  8:13   ` Amelie Delaunay
2025-11-17 16:12 ` [PATCH 11/15] dmaengine: stm32: dmamux: clean up route allocation error labels Johan Hovold
2025-11-18  8:14   ` Amelie Delaunay
2025-11-17 16:12 ` [PATCH 12/15] dmaengine: ti: dma-crossbar: fix device leak on dra7x route allocation Johan Hovold
2025-11-17 16:12 ` [PATCH 13/15] dmaengine: ti: dma-crossbar: fix device leak on am335x " Johan Hovold
2025-11-17 16:12 ` [PATCH 14/15] dmaengine: ti: dma-crossbar: clean up dra7x route allocation error paths Johan Hovold
2025-11-17 16:12 ` [PATCH 15/15] dmaengine: ti: k3-udma: fix device leak on udma lookup Johan Hovold
2025-11-22  9:14 ` [PATCH 00/15] dmaengine: fix device leaks Vinod Koul
2025-12-16 16:56 ` Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251117161258.10679-10-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=amelie.delaunay@foss.st.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=fabrizio.castro.jz@renesas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ludovic.desroches@microchip.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=peter.ujfalusi@gmail.com \
    --cc=piotr.wojtaszczyk@timesys.com \
    --cc=stable@vger.kernel.org \
    --cc=vinicius.gomes@intel.com \
    --cc=vireshk@kernel.org \
    --cc=vkoul@kernel.org \
    --cc=vz@mleia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).