DMA Engine development
 help / color / mirror / Atom feed
* [PATCH] dmaengine: dw: dmamux: Fix device reference leak in rzn1_dmamux_route_allocate
@ 2025-09-02  9:03 Miaoqian Lin
  2025-09-02  9:18 ` Miquel Raynal
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Miaoqian Lin @ 2025-09-02  9:03 UTC (permalink / raw)
  To: Viresh Kumar, Andy Shevchenko, Vinod Koul, Miquel Raynal,
	Ilpo Järvinen, dmaengine, linux-kernel
  Cc: linmq006, stable

The reference taken by of_find_device_by_node()
must be released when not needed anymore.
Add missing put_device() call to fix device reference leaks.

Fixes: 134d9c52fca2 ("dmaengine: dw: dmamux: Introduce RZN1 DMA router support")
Cc: stable@vger.kernel.org
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/dma/dw/rzn1-dmamux.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/dw/rzn1-dmamux.c b/drivers/dma/dw/rzn1-dmamux.c
index 4fb8508419db..deadf135681b 100644
--- a/drivers/dma/dw/rzn1-dmamux.c
+++ b/drivers/dma/dw/rzn1-dmamux.c
@@ -48,12 +48,16 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
 	u32 mask;
 	int ret;
 
-	if (dma_spec->args_count != RNZ1_DMAMUX_NCELLS)
-		return ERR_PTR(-EINVAL);
+	if (dma_spec->args_count != RNZ1_DMAMUX_NCELLS) {
+		ret = -EINVAL;
+		goto put_device;
+	}
 
 	map = kzalloc(sizeof(*map), GFP_KERNEL);
-	if (!map)
-		return ERR_PTR(-ENOMEM);
+	if (!map) {
+		ret = -ENOMEM;
+		goto put_device;
+	}
 
 	chan = dma_spec->args[0];
 	map->req_idx = dma_spec->args[4];
@@ -94,12 +98,15 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
 	if (ret)
 		goto clear_bitmap;
 
+	put_device(&pdev->dev);
 	return map;
 
 clear_bitmap:
 	clear_bit(map->req_idx, dmamux->used_chans);
 free_map:
 	kfree(map);
+put_device:
+	put_device(&pdev->dev);
 
 	return ERR_PTR(ret);
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-09-02 13:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-02  9:03 [PATCH] dmaengine: dw: dmamux: Fix device reference leak in rzn1_dmamux_route_allocate Miaoqian Lin
2025-09-02  9:18 ` Miquel Raynal
2025-09-02  9:24 ` Markus Elfring
2025-09-02  9:35 ` Vinod Koul
2025-09-02  9:37 ` Andy Shevchenko
2025-09-02 10:18   ` 林妙倩
2025-09-02 11:02     ` Andy Shevchenko
2025-09-02 13:12       ` 林妙倩
2025-09-02 13:30     ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox