Netdev List
 help / color / mirror / Atom feed
* [PATCH net] ice: Avoid tracing bridge ports after initialization failure
@ 2026-11-18  7:42 Alex Kazinsky
  2026-11-18  7:48 ` netdev-bot+sinfo
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Kazinsky @ 2026-11-18  7:42 UTC (permalink / raw)
  To: Tony Nguyen
  Cc: Alex Kazinsky, Przemek Kitszel, Andrew Lunn, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Pawel Chmielewski,
	Wojciech Drewek, intel-wired-lan, netdev, linux-kernel,
	lvc-project, stable

ice_eswitch_br_port_link() traces representor and uplink bridge ports
before checking whether their initialization succeeded. If allocation
fails, the port pointer remains NULL. If xa_insert() fails, the cleanup
path clears the pointer and frees the port.

With the ice_eswitch_br_port_link trace event enabled, its handler
dereferences the NULL pointer while reading the port fields.

Call the tracepoint only after successful port initialization.

Found by Linux Verification Center (linuxtesting.org) with SVACE static
analysis tool.

Fixes: d129c2a245bf ("ice: add tracepoints for the switchdev bridge")
Cc: stable@vger.kernel.org
Signed-off-by: Alex Kazinsky <a.kazinsky@ideco.ru>
---
 drivers/net/ethernet/intel/ice/ice_eswitch_br.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch_br.c b/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
index 1d8a6b95ccda..6d07c15ba9d8 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
@@ -1118,7 +1118,8 @@ ice_eswitch_br_port_link(struct ice_esw_br_offloads *br_offloads,
 		struct ice_repr *repr = ice_netdev_to_repr(dev);
 
 		err = ice_eswitch_br_vf_repr_port_init(bridge, repr);
-		trace_ice_eswitch_br_port_link(repr->br_port);
+		if (!err)
+			trace_ice_eswitch_br_port_link(repr->br_port);
 	} else {
 		struct net_device *ice_dev;
 		struct ice_pf *pf;
@@ -1134,7 +1135,8 @@ ice_eswitch_br_port_link(struct ice_esw_br_offloads *br_offloads,
 		pf = ice_netdev_to_pf(ice_dev);
 
 		err = ice_eswitch_br_uplink_port_init(bridge, pf);
-		trace_ice_eswitch_br_port_link(pf->br_port);
+		if (!err)
+			trace_ice_eswitch_br_port_link(pf->br_port);
 	}
 	if (err) {
 		NL_SET_ERR_MSG_MOD(extack, "Failed to init bridge port");
-- 
2.56.0



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

end of thread, other threads:[~2026-11-18  8:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18  7:42 [PATCH net] ice: Avoid tracing bridge ports after initialization failure Alex Kazinsky
2026-11-18  7:48 ` netdev-bot+sinfo
2026-11-18  8:00   ` Алексей Казинский

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox