mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Amelie Delaunay <amelie.delaunay@foss.st.com>
To: Johan Hovold <johan@kernel.org>, 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>,
	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>,
	<stable@vger.kernel.org>,
	Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>
Subject: Re: [PATCH 09/15] dmaengine: stm32: dmamux: fix device leak on route allocation
Date: Tue, 18 Nov 2025 09:11:30 +0100	[thread overview]
Message-ID: <ec4001b1-e7b5-4d7d-8665-2b5d5a843c8c@foss.st.com> (raw)
In-Reply-To: <20251117161258.10679-11-johan@kernel.org>



On 11/17/25 17:12, Johan Hovold wrote:
> Make sure to drop the reference taken when looking up the DMA mux
> platform device during route allocation.
> 
> Note that holding a reference to a device does not prevent its driver
> data from going away so there is no point in keeping the reference.
> 
> Fixes: df7e762db5f6 ("dmaengine: Add STM32 DMAMUX driver")
> Cc: stable@vger.kernel.org	# 4.15
> Cc: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>

> ---
>   drivers/dma/stm32/stm32-dmamux.c | 18 ++++++++++++------
>   1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/dma/stm32/stm32-dmamux.c b/drivers/dma/stm32/stm32-dmamux.c
> index 8d77e2a7939a..791179760782 100644
> --- a/drivers/dma/stm32/stm32-dmamux.c
> +++ b/drivers/dma/stm32/stm32-dmamux.c
> @@ -90,23 +90,25 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
>   	struct stm32_dmamux_data *dmamux = platform_get_drvdata(pdev);
>   	struct stm32_dmamux *mux;
>   	u32 i, min, max;
> -	int ret;
> +	int ret = -EINVAL;
>   	unsigned long flags;
>   
>   	if (dma_spec->args_count != 3) {
>   		dev_err(&pdev->dev, "invalid number of dma mux args\n");
> -		return ERR_PTR(-EINVAL);
> +		goto err_put_pdev;
>   	}
>   
>   	if (dma_spec->args[0] > dmamux->dmamux_requests) {
>   		dev_err(&pdev->dev, "invalid mux request number: %d\n",
>   			dma_spec->args[0]);
> -		return ERR_PTR(-EINVAL);
> +		goto err_put_pdev;
>   	}
>   
>   	mux = kzalloc(sizeof(*mux), GFP_KERNEL);
> -	if (!mux)
> -		return ERR_PTR(-ENOMEM);
> +	if (!mux) {
> +		ret = -ENOMEM;
> +		goto err_put_pdev;
> +	}
>   
>   	spin_lock_irqsave(&dmamux->lock, flags);
>   	mux->chan_id = find_first_zero_bit(dmamux->dma_inuse,
> @@ -133,7 +135,6 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
>   	dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", i - 1);
>   	if (!dma_spec->np) {
>   		dev_err(&pdev->dev, "can't get dma master\n");
> -		ret = -EINVAL;
>   		goto error;
>   	}
>   
> @@ -160,6 +161,8 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
>   	dev_dbg(&pdev->dev, "Mapping DMAMUX(%u) to DMA%u(%u)\n",
>   		mux->request, mux->master, mux->chan_id);
>   
> +	put_device(&pdev->dev);
> +
>   	return mux;
>   
>   error:
> @@ -167,6 +170,9 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
>   
>   error_chan_id:
>   	kfree(mux);
> +err_put_pdev:
> +	put_device(&pdev->dev);
> +
>   	return ERR_PTR(ret);
>   }
>   


  reply	other threads:[~2025-11-18  8:12 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 ` [PATCH 08/15] dmaengine: sh: rz-dmac: fix device leak on probe failure Johan Hovold
2025-11-18 13:49   ` 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 [this message]
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=ec4001b1-e7b5-4d7d-8665-2b5d5a843c8c@foss.st.com \
    --to=amelie.delaunay@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ludovic.desroches@microchip.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=peter.ujfalusi@gmail.com \
    --cc=pierre-yves.mordret@foss.st.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

all inboxes | Powered by JetHome®