Skip to content

Commit 221f673

Browse files
Yuuoniygregkh
authored andcommitted
dmaengine: dw: dmamux: Fix device reference leak in rzn1_dmamux_route_allocate
commit aa2e1e4 upstream. 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: 134d9c5 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ebf6c7c commit 221f673

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/dma/dw/rzn1-dmamux.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
4848
u32 mask;
4949
int ret;
5050

51-
if (dma_spec->args_count != RNZ1_DMAMUX_NCELLS)
52-
return ERR_PTR(-EINVAL);
51+
if (dma_spec->args_count != RNZ1_DMAMUX_NCELLS) {
52+
ret = -EINVAL;
53+
goto put_device;
54+
}
5355

5456
map = kzalloc(sizeof(*map), GFP_KERNEL);
55-
if (!map)
56-
return ERR_PTR(-ENOMEM);
57+
if (!map) {
58+
ret = -ENOMEM;
59+
goto put_device;
60+
}
5761

5862
chan = dma_spec->args[0];
5963
map->req_idx = dma_spec->args[4];
@@ -94,12 +98,15 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
9498
if (ret)
9599
goto clear_bitmap;
96100

101+
put_device(&pdev->dev);
97102
return map;
98103

99104
clear_bitmap:
100105
clear_bit(map->req_idx, dmamux->used_chans);
101106
free_map:
102107
kfree(map);
108+
put_device:
109+
put_device(&pdev->dev);
103110

104111
return ERR_PTR(ret);
105112
}

0 commit comments

Comments
 (0)