linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: xilinx: axienet: Reduce scopes for two resources in axienet_probe()
@ 2024-09-20  9:22 Markus Elfring
  2024-09-22 16:59 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2024-09-20  9:22 UTC (permalink / raw)
  To: netdev, linux-arm-kernel, Andy Chiu, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Michal Simek, Paolo Abeni,
	Radhey Shyam Pandey
  Cc: LKML, kernel-janitors, Sean Anderson

From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
 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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: xilinx: axienet: Reduce scopes for two resources in axienet_probe()
  2024-09-20  9:22 [PATCH] net: xilinx: axienet: Reduce scopes for two resources in axienet_probe() Markus Elfring
@ 2024-09-22 16:59 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2024-09-22 16:59 UTC (permalink / raw)
  To: Markus Elfring
  Cc: netdev, linux-arm-kernel, Andy Chiu, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Michal Simek, Paolo Abeni,
	Radhey Shyam Pandey, LKML, kernel-janitors, Sean Anderson

On Fri, Sep 20, 2024 at 11:22:47AM +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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 <elfring@users.sourceforge.net>

Hi Markus,

This change seems reasonable to me.  However, I am assuming that as a
non-bug-fix, this is targeted at net-next.  And net-next is currently
closed for the v6.12 merge window.  Please consider reposting this patch
once net-next reopens.  That will occur after v6.12-rc1 has been released.
Which I expect to be about a week from now.

Also, for networking patches please tag non-bug fixes for
net-next (and bug fixes for net, being sure to include a Fixes tag).

	Subject: [PATCH net-next] ...

Please see https://docs.kernel.org/process/maintainer-netdev.html

-- 
pw-bot: defer


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-22 17:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-20  9:22 [PATCH] net: xilinx: axienet: Reduce scopes for two resources in axienet_probe() Markus Elfring
2024-09-22 16:59 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).