quoted
Would an "echo netdev > /sys/class/leds/<led>/trigger" racing with switch
unbind, or with the dsa_tree_setup() error path, touch a freed
net_device here? Would removing the LEDs per port before the netdevs go
away, or validating dp->user under rtnl_lock, avoid that?
quoted
@@ -4581,6 +4589,12 @@ static int yt921x_dsa_setup(struct dsa_switch *ds)
if (res)
return res;
+#if IS_ENABLED(CONFIG_NET_DSA_YT921X_LEDS)
+ res = yt921x_leds_setup(priv);
+ if (res)
+ dev_warn(dev, "Failed to setup LEDs: %d\n", res);
+#endif
+
Just a question: I don't see any protection against this in other DSA
led drivers, like mv88e6 or qca8k.
Registering the LEDs uses devm_ so the life of the LEDs is the life of
the chip. The LED trigger does however take a reference on the network
device, so it should not be possible for it to disappear while the
trigger is still bound to it.
Andrew