lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ec4001b1-e7b5-4d7d-8665-2b5d5a843c8c@foss.st.com>
Date: Tue, 18 Nov 2025 09:11:30 +0100
From: Amelie Delaunay <amelie.delaunay@...s.st.com>
To: Johan Hovold <johan@...nel.org>, Vinod Koul <vkoul@...nel.org>
CC: Ludovic Desroches <ludovic.desroches@...rochip.com>,
        Viresh Kumar
	<vireshk@...nel.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Vinicius Costa Gomes <vinicius.gomes@...el.com>,
        Dave Jiang
	<dave.jiang@...el.com>, Vladimir Zapolskiy <vz@...ia.com>,
        Piotr Wojtaszczyk
	<piotr.wojtaszczyk@...esys.com>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Alexandre Torgue <alexandre.torgue@...s.st.com>,
        Peter Ujfalusi
	<peter.ujfalusi@...il.com>,
        <dmaengine@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <stable@...r.kernel.org>,
        Pierre-Yves MORDRET
	<pierre-yves.mordret@...s.st.com>
Subject: Re: [PATCH 09/15] dmaengine: stm32: dmamux: fix device leak on route
 allocation



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@...r.kernel.org	# 4.15
> Cc: Pierre-Yves MORDRET <pierre-yves.mordret@...s.st.com>
> Signed-off-by: Johan Hovold <johan@...nel.org>

Reviewed-by: Amelie Delaunay <amelie.delaunay@...s.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);
>   }
>   


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ