Thread (2 messages) 2 messages, 2 authors, 2024-09-22
STALE663d

[PATCH] net: xilinx: axienet: Reduce scopes for two resources in axienet_probe()

From: Markus Elfring <hidden>
Date: 2024-09-20 09:23:47
Also in: kernel-janitors, linux-arm-kernel, lkml
Subsystem: networking drivers, the rest, xilinx axi ethernet driver · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds, Radhey Shyam Pandey

From: Markus Elfring <redacted>
Date: Fri, 20 Sep 2024 11:08:10 +0200

The calls “dma_release_channel(tx_chan)” and “of_node_put(np)”
were immediately used after return value checks in this
function implementation.
Thus use such function calls only once instead directly before the checks.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <redacted>
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index ea7d7c03f48e..e3d9801ad17e 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -2806,13 +2806,12 @@ static int axienet_probe(struct platform_device *pdev)
 		cfg.reset = 1;
 		/* As name says VDMA but it has support for DMA channel reset */
 		ret = xilinx_vdma_channel_set_config(tx_chan, &cfg);
+		dma_release_channel(tx_chan);
 		if (ret < 0) {
 			dev_err(&pdev->dev, "Reset channel failed\n");
-			dma_release_channel(tx_chan);
 			goto cleanup_clk;
 		}

-		dma_release_channel(tx_chan);
 		lp->use_dmaengine = 1;
 	}
@@ -2860,12 +2859,12 @@ static int axienet_probe(struct platform_device *pdev)
 			goto cleanup_mdio;
 		}
 		lp->pcs_phy = of_mdio_find_device(np);
+		of_node_put(np);
 		if (!lp->pcs_phy) {
 			ret = -EPROBE_DEFER;
-			of_node_put(np);
 			goto cleanup_mdio;
 		}
-		of_node_put(np);
+
 		lp->pcs.ops = &axienet_pcs_ops;
 		lp->pcs.neg_mode = true;
 		lp->pcs.poll = true;
--
2.46.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help