[PATCH net] ice: Avoid tracing bridge ports after initialization failure
From: Alex Kazinsky
Date: Wed Nov 18 2026 - 02:43:48 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Alex Kazinsky <a.kazinsky@xxxxxxxx>
---
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