Skip to content

Commit 4fc17b1

Browse files
jhovoldvinodkoul
authored andcommitted
dmaengine: ti: dma-crossbar: fix device leak on am335x route allocation
Make sure to drop the reference taken when looking up the crossbar platform device during am335x route allocation. Fixes: 42dbdcc ("dmaengine: ti-dma-crossbar: Add support for crossbar on AM33xx/AM43xx") Cc: stable@vger.kernel.org # 4.4 Cc: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20251117161258.10679-15-johan@kernel.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent dc7e44d commit 4fc17b1

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

drivers/dma/ti/dma-crossbar.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,34 +79,35 @@ static void *ti_am335x_xbar_route_allocate(struct of_phandle_args *dma_spec,
7979
{
8080
struct platform_device *pdev = of_find_device_by_node(ofdma->of_node);
8181
struct ti_am335x_xbar_data *xbar = platform_get_drvdata(pdev);
82-
struct ti_am335x_xbar_map *map;
82+
struct ti_am335x_xbar_map *map = ERR_PTR(-EINVAL);
8383

8484
if (dma_spec->args_count != 3)
85-
return ERR_PTR(-EINVAL);
85+
goto out_put_pdev;
8686

8787
if (dma_spec->args[2] >= xbar->xbar_events) {
8888
dev_err(&pdev->dev, "Invalid XBAR event number: %d\n",
8989
dma_spec->args[2]);
90-
return ERR_PTR(-EINVAL);
90+
goto out_put_pdev;
9191
}
9292

9393
if (dma_spec->args[0] >= xbar->dma_requests) {
9494
dev_err(&pdev->dev, "Invalid DMA request line number: %d\n",
9595
dma_spec->args[0]);
96-
return ERR_PTR(-EINVAL);
96+
goto out_put_pdev;
9797
}
9898

9999
/* The of_node_put() will be done in the core for the node */
100100
dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
101101
if (!dma_spec->np) {
102102
dev_err(&pdev->dev, "Can't get DMA master\n");
103-
return ERR_PTR(-EINVAL);
103+
goto out_put_pdev;
104104
}
105105

106106
map = kzalloc(sizeof(*map), GFP_KERNEL);
107107
if (!map) {
108108
of_node_put(dma_spec->np);
109-
return ERR_PTR(-ENOMEM);
109+
map = ERR_PTR(-ENOMEM);
110+
goto out_put_pdev;
110111
}
111112

112113
map->dma_line = (u16)dma_spec->args[0];
@@ -120,6 +121,9 @@ static void *ti_am335x_xbar_route_allocate(struct of_phandle_args *dma_spec,
120121

121122
ti_am335x_xbar_write(xbar->iomem, map->dma_line, map->mux_val);
122123

124+
out_put_pdev:
125+
put_device(&pdev->dev);
126+
123127
return map;
124128
}
125129

0 commit comments

Comments
 (0)