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

dmaengine: ti: dma-crossbar: clean up dra7x route allocation error paths

Use a common exit path to drop the cross platform device reference on
errors for consistency with am335x.

Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20251117161258.10679-16-johan@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Johan Hovold and committed by
Vinod Koul
646ff780 4fc17b1c

+8 -9
+8 -9
drivers/dma/ti/dma-crossbar.c
··· 245 245 { 246 246 struct platform_device *pdev = of_find_device_by_node(ofdma->of_node); 247 247 struct ti_dra7_xbar_data *xbar = platform_get_drvdata(pdev); 248 - struct ti_dra7_xbar_map *map; 248 + struct ti_dra7_xbar_map *map = ERR_PTR(-EINVAL); 249 249 250 250 if (dma_spec->args[0] >= xbar->xbar_requests) { 251 251 dev_err(&pdev->dev, "Invalid XBAR request number: %d\n", 252 252 dma_spec->args[0]); 253 - put_device(&pdev->dev); 254 - return ERR_PTR(-EINVAL); 253 + goto out_put_pdev; 255 254 } 256 255 257 256 /* The of_node_put() will be done in the core for the node */ 258 257 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0); 259 258 if (!dma_spec->np) { 260 259 dev_err(&pdev->dev, "Can't get DMA master\n"); 261 - put_device(&pdev->dev); 262 - return ERR_PTR(-EINVAL); 260 + goto out_put_pdev; 263 261 } 264 262 265 263 map = kzalloc(sizeof(*map), GFP_KERNEL); 266 264 if (!map) { 267 265 of_node_put(dma_spec->np); 268 - put_device(&pdev->dev); 269 - return ERR_PTR(-ENOMEM); 266 + map = ERR_PTR(-ENOMEM); 267 + goto out_put_pdev; 270 268 } 271 269 272 270 mutex_lock(&xbar->mutex); ··· 275 277 dev_err(&pdev->dev, "Run out of free DMA requests\n"); 276 278 kfree(map); 277 279 of_node_put(dma_spec->np); 278 - put_device(&pdev->dev); 279 - return ERR_PTR(-ENOMEM); 280 + map = ERR_PTR(-ENOMEM); 281 + goto out_put_pdev; 280 282 } 281 283 set_bit(map->xbar_out, xbar->dma_inuse); 282 284 mutex_unlock(&xbar->mutex); ··· 290 292 291 293 ti_dra7_xbar_write(xbar->iomem, map->xbar_out, map->xbar_in); 292 294 295 + out_put_pdev: 293 296 put_device(&pdev->dev); 294 297 295 298 return map;