mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Andy Chiu <andy.chiu@sifive.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Michal Simek <michal.simek@amd.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Sean Anderson <sean.anderson@linux.dev>
Subject: [PATCH] net: xilinx: axienet: Reduce scopes for two resources in axienet_probe()
Date: Fri, 20 Sep 2024 11:22:47 +0200	[thread overview]
Message-ID: <2e6f6f8f-89de-4b75-a0af-3a55bc046ab7@web.de> (raw)

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


             reply	other threads:[~2024-09-20  9:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-20  9:22 Markus Elfring [this message]
2024-09-22 16:59 ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2e6f6f8f-89de-4b75-a0af-3a55bc046ab7@web.de \
    --to=markus.elfring@web.de \
    --cc=andy.chiu@sifive.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=radhey.shyam.pandey@amd.com \
    --cc=sean.anderson@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®