Skip to contentSkip to conversation

dmaengine: of-dma: Fix of_dma_router_xlate's of_dma_xlate handling

PATCH Applied Peter Ujfalusi 2 participants 2 messages Aug 6, 2020 – Aug 17, 2020 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: of-dma: Fix of_dma_router_xlate's of_dma_xlate handling

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 56f13c0d9524c ("dmaengine: of_dma: Support for DMA routers")
---
 drivers/dma/of-dma.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/dma/of-dma.c +4 -4
index 863f2aaf5c8f..8a4f608904b9 100644
@@ -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;
 	}
 
 	/*
Signature · 10 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Applied
#1 lore raw
Quoted 4 lines · Peter Ujfalusi

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.

Applied, thanks

Signature · 1 line
~Vinod