]> git.baikalelectronics.ru Git - kernel.git/commitdiff
dmaengine: of-dma: Fix of_dma_router_xlate's of_dma_xlate handling
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Thu, 6 Aug 2020 10:49:28 +0000 (13:49 +0300)
committerVinod Koul <vkoul@kernel.org>
Mon, 17 Aug 2020 05:44:28 +0000 (11:14 +0530)
of_dma_xlate callback can return ERR_PTR as well NULL in case of failure.

If error code is returned (not NULL) then the route should be released and
the router should not be registered for the channel.

Fixes: 2752dcc37a8a7 ("dmaengine: of_dma: Support for DMA routers")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20200806104928.25975-1-peter.ujfalusi@ti.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/of-dma.c

index 863f2aaf5c8f7fa037f5303c2cf1c4af4bb5f5d4..8a4f608904b984c65bf4211aaffb4fcd9fc37b4b 100644 (file)
@@ -71,12 +71,12 @@ static struct dma_chan *of_dma_router_xlate(struct of_phandle_args *dma_spec,
                return NULL;
 
        chan = ofdma_target->of_dma_xlate(&dma_spec_target, ofdma_target);
-       if (chan) {
-               chan->router = ofdma->dma_router;
-               chan->route_data = route_data;
-       } else {
+       if (IS_ERR_OR_NULL(chan)) {
                ofdma->dma_router->route_free(ofdma->dma_router->dev,
                                              route_data);
+       } else {
+               chan->router = ofdma->dma_router;
+               chan->route_data = route_data;
        }
 
        /*