dmaengine: xilinx_dma: call of_node_put() when breaking out of for_each_child_of_node()

Message ID 20221122021612.1908866-1-liushixin2@huawei.com
State New
Headers
Series dmaengine: xilinx_dma: call of_node_put() when breaking out of for_each_child_of_node() |

Commit Message

Liu Shixin Nov. 22, 2022, 2:16 a.m. UTC
  Since for_each_child_of_node() will increase the refcount of node, we need
to call of_node_put() manually when breaking out of the iteration.

Fixes: 9cd4360de609 ("dma: Add Xilinx AXI Video Direct Memory Access Engine driver support")
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 drivers/dma/xilinx/xilinx_dma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Peter Korsgaard Nov. 22, 2022, 6:59 a.m. UTC | #1
>>>>> "Liu" == Liu Shixin <liushixin2@huawei.com> writes:

 > Since for_each_child_of_node() will increase the refcount of node, we need
 > to call of_node_put() manually when breaking out of the iteration.

 > Fixes: 9cd4360de609 ("dma: Add Xilinx AXI Video Direct Memory Access Engine driver support")
 > Signed-off-by: Liu Shixin <liushixin2@huawei.com>

Acked-by: Peter Korsgaard <peter@korsgaard.com>

> ---
 >  drivers/dma/xilinx/xilinx_dma.c | 4 +++-
 >  1 file changed, 3 insertions(+), 1 deletion(-)

 > diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
 > index 8cd4e69dc7b4..766017570488 100644
 > --- a/drivers/dma/xilinx/xilinx_dma.c
 > +++ b/drivers/dma/xilinx/xilinx_dma.c
 > @@ -3141,8 +3141,10 @@ static int xilinx_dma_probe(struct platform_device *pdev)
 >  	/* Initialize the channels */
 >  	for_each_child_of_node(node, child) {
 >  		err = xilinx_dma_child_probe(xdev, child);
 > -		if (err < 0)
 > +		if (err < 0) {
 > +			of_node_put(child);
 >  			goto error;
 > +		}
 >  	}
 
 >  	if (xdev->dma_config->dmatype == XDMA_TYPE_VDMA) {
 > -- 

 > 2.25.1
  

Patch

diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index 8cd4e69dc7b4..766017570488 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -3141,8 +3141,10 @@  static int xilinx_dma_probe(struct platform_device *pdev)
 	/* Initialize the channels */
 	for_each_child_of_node(node, child) {
 		err = xilinx_dma_child_probe(xdev, child);
-		if (err < 0)
+		if (err < 0) {
+			of_node_put(child);
 			goto error;
+		}
 	}
 
 	if (xdev->dma_config->dmatype == XDMA_TYPE_VDMA) {