Skip to content

Commit d9c8ad9

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 555bd16 commit d9c8ad9

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
@@ -46,12 +46,16 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
4646
u32 mask;
4747
int ret;
4848

49-
if (dma_spec->args_count != RNZ1_DMAMUX_NCELLS)
50-
return ERR_PTR(-EINVAL);
49+
if (dma_spec->args_count != RNZ1_DMAMUX_NCELLS) {
50+
ret = -EINVAL;
51+
goto put_device;
52+
}
5153

5254
map = kzalloc(sizeof(*map), GFP_KERNEL);
53-
if (!map)
54-
return ERR_PTR(-ENOMEM);
55+
if (!map) {
56+
ret = -ENOMEM;
57+
goto put_device;
58+
}
5559

5660
chan = dma_spec->args[0];
5761
map->req_idx = dma_spec->args[4];
@@ -92,12 +96,15 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
9296
if (ret)
9397
goto clear_bitmap;
9498

99+
put_device(&pdev->dev);
95100
return map;
96101

97102
clear_bitmap:
98103
clear_bit(map->req_idx, dmamux->used_chans);
99104
free_map:
100105
kfree(map);
106+
put_device:
107+
put_device(&pdev->dev);
101108

102109
return ERR_PTR(ret);
103110
}

0 commit comments

Comments
 (0)