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] [day] [month] [year] [list]
Message-ID: <5fd6185d-ac56-4540-b280-ffe7321315bd@mleia.com>
Date: Mon, 17 Nov 2025 21:27:15 +0200
From: Vladimir Zapolskiy <vz@...ia.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>,
 Piotr Wojtaszczyk <piotr.wojtaszczyk@...esys.com>,
 Amélie Delaunay <amelie.delaunay@...s.st.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
Subject: Re: [PATCH 07/15] dmaengine: lpc32xx-dmamux: fix device leak on route
 allocation

On 11/17/25 18: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: 5d318b595982 ("dmaengine: Add dma router for pl08x in LPC32XX SoC")
> Cc: stable@...r.kernel.org	# 6.12
> Cc: Piotr Wojtaszczyk <piotr.wojtaszczyk@...esys.com>
> Signed-off-by: Johan Hovold <johan@...nel.org>
> ---
>   drivers/dma/lpc32xx-dmamux.c | 19 ++++++++++++++-----
>   1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/dma/lpc32xx-dmamux.c b/drivers/dma/lpc32xx-dmamux.c
> index 351d7e23e615..33be714740dd 100644
> --- a/drivers/dma/lpc32xx-dmamux.c
> +++ b/drivers/dma/lpc32xx-dmamux.c
> @@ -95,11 +95,12 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_args *dma_spec,
>   	struct lpc32xx_dmamux_data *dmamux = platform_get_drvdata(pdev);
>   	unsigned long flags;
>   	struct lpc32xx_dmamux *mux = NULL;
> +	int ret = -EINVAL;
>   	int i;
>   
>   	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;
>   	}
>   
>   	for (i = 0; i < ARRAY_SIZE(lpc32xx_muxes); i++) {
> @@ -111,20 +112,20 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_args *dma_spec,
>   	if (!mux) {
>   		dev_err(&pdev->dev, "invalid mux request number: %d\n",
>   			dma_spec->args[0]);
> -		return ERR_PTR(-EINVAL);
> +		goto err_put_pdev;
>   	}
>   
>   	if (dma_spec->args[2] > 1) {
>   		dev_err(&pdev->dev, "invalid dma mux value: %d\n",
>   			dma_spec->args[1]);
> -		return ERR_PTR(-EINVAL);
> +		goto err_put_pdev;
>   	}
>   
>   	/* The of_node_put() will be done in the core for the node */
>   	dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
>   	if (!dma_spec->np) {
>   		dev_err(&pdev->dev, "can't get dma master\n");
> -		return ERR_PTR(-EINVAL);
> +		goto err_put_pdev;
>   	}
>   
>   	spin_lock_irqsave(&dmamux->lock, flags);
> @@ -133,7 +134,8 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_args *dma_spec,
>   		dev_err(dev, "dma request signal %d busy, routed to %s\n",
>   			mux->signal, mux->muxval ? mux->name_sel1 : mux->name_sel1);
>   		of_node_put(dma_spec->np);
> -		return ERR_PTR(-EBUSY);
> +		ret = -EBUSY;
> +		goto err_put_pdev;
>   	}
>   
>   	mux->busy = true;
> @@ -148,7 +150,14 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_args *dma_spec,
>   	dev_dbg(dev, "dma request signal %d routed to %s\n",
>   		mux->signal, mux->muxval ? mux->name_sel1 : mux->name_sel1);
>   
> +	put_device(&pdev->dev);
> +
>   	return mux;
> +
> +err_put_pdev:
> +	put_device(&pdev->dev);
> +
> +	return ERR_PTR(ret);
>   }
>   
>   static int lpc32xx_dmamux_probe(struct platform_device *pdev)

Reviewed-by: Vladimir Zapolskiy <vz@...ia.com>

-- 
Best wishes,
Vladimir

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ