]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dmaengine: dw: dmamux: Fix device reference leak in rzn1_dmamux_route_allocate
authorMiaoqian Lin <linmq006@gmail.com>
Tue, 2 Sep 2025 09:03:58 +0000 (17:03 +0800)
committerVinod Koul <vkoul@kernel.org>
Tue, 2 Sep 2025 09:31:51 +0000 (15:01 +0530)
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>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20250902090358.2423285-1-linmq006@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/dw/rzn1-dmamux.c

index 4fb8508419dbd8afdffb3cc57a21a0a76aae26ad..deadf135681b673c2b55c6a94a2622f95f30ec89 100644 (file)
@@ -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);
 }