Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 42dbdcc6bf96 ("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>

authored by

Johan Hovold and committed by
Vinod Koul
4fc17b1c dc7e44db

+10 -6
+10 -6
drivers/dma/ti/dma-crossbar.c
··· 79 79 { 80 80 struct platform_device *pdev = of_find_device_by_node(ofdma->of_node); 81 81 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); 83 83 84 84 if (dma_spec->args_count != 3) 85 - return ERR_PTR(-EINVAL); 85 + goto out_put_pdev; 86 86 87 87 if (dma_spec->args[2] >= xbar->xbar_events) { 88 88 dev_err(&pdev->dev, "Invalid XBAR event number: %d\n", 89 89 dma_spec->args[2]); 90 - return ERR_PTR(-EINVAL); 90 + goto out_put_pdev; 91 91 } 92 92 93 93 if (dma_spec->args[0] >= xbar->dma_requests) { 94 94 dev_err(&pdev->dev, "Invalid DMA request line number: %d\n", 95 95 dma_spec->args[0]); 96 - return ERR_PTR(-EINVAL); 96 + goto out_put_pdev; 97 97 } 98 98 99 99 /* The of_node_put() will be done in the core for the node */ 100 100 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0); 101 101 if (!dma_spec->np) { 102 102 dev_err(&pdev->dev, "Can't get DMA master\n"); 103 - return ERR_PTR(-EINVAL); 103 + goto out_put_pdev; 104 104 } 105 105 106 106 map = kzalloc(sizeof(*map), GFP_KERNEL); 107 107 if (!map) { 108 108 of_node_put(dma_spec->np); 109 - return ERR_PTR(-ENOMEM); 109 + map = ERR_PTR(-ENOMEM); 110 + goto out_put_pdev; 110 111 } 111 112 112 113 map->dma_line = (u16)dma_spec->args[0]; ··· 120 119 map->mux_val, map->dma_line); 121 120 122 121 ti_am335x_xbar_write(xbar->iomem, map->dma_line, map->mux_val); 122 + 123 + out_put_pdev: 124 + put_device(&pdev->dev); 123 125 124 126 return map; 125 127 }