mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Selby Mashiki <mashikiselby@gmail.com>
To: Horatiu Vultur <horatiu.vultur@microchip.com>,
	UNGLinuxDriver@microchip.com, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Selby Mashiki <mashikiselby@gmail.com>
Subject: [PATCH] net: lan966x: fix double fwnode_handle_put() and missing mdb deinit in probe error path
Date: Sun, 25 Oct 2026 22:31:55 +0200	[thread overview]
Message-ID: <20261025203155.455075-1-mashikiselby@gmail.com> (raw)

In lan966x_probe(), fwnode_handle_put(ports) is called after the
fwnode_for_each_available_child_node(ports, portnp) loop finishes.
However, if lan966x_fdb_init(), lan966x_ptp_init(), lan966x_fdma_init(),
or lan966x_vcap_init() subsequently fails, execution jumps to or falls
through to cleanup_ports, calling fwnode_handle_put(ports) a second time
and skipping lan966x_mdb_deinit().

Add cleanup_mdb and cleanup_switch labels so post-loop initialization
failures deinitialize MDB and clean up ports without calling
fwnode_handle_put() on ports again.

Signed-off-by: Selby Mashiki <mashikiselby@gmail.com>
---
 drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
index 1179a6e12..7abfd97ad 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
@@ -1228,7 +1228,7 @@ static int lan966x_probe(struct platform_device *pdev)
 	lan966x_mdb_init(lan966x);
 	err = lan966x_fdb_init(lan966x);
 	if (err)
-		goto cleanup_ports;
+		goto cleanup_mdb;
 
 	err = lan966x_ptp_init(lan966x);
 	if (err)
@@ -1255,10 +1255,15 @@ static int lan966x_probe(struct platform_device *pdev)
 cleanup_fdb:
 	lan966x_fdb_deinit(lan966x);
 
+cleanup_mdb:
+	lan966x_mdb_deinit(lan966x);
+	goto cleanup_switch;
+
 cleanup_ports:
 	fwnode_handle_put(ports);
 	fwnode_handle_put(portnp);
 
+cleanup_switch:
 	lan966x_cleanup_ports(lan966x);
 
 	cancel_delayed_work_sync(&lan966x->stats_work);
-- 
2.56.0

             reply	other threads:[~2026-10-25 20:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-25 20:31 Selby Mashiki [this message]
2026-10-25 20:35 ` netdev-bot+sinfo
2026-10-25 20:37 ` Selby Mashiki
2026-10-26  7:21 ` Daniel Machon
2026-10-26 21:09 ` netdev-bot+sashiko

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=20261025203155.455075-1-mashikiselby@gmail.com \
    --to=mashikiselby@gmail.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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®