Re: [PATCH linux next] net: dsa: fix the dsa_ptr null pointer dereference
From: Markus Elfring
Date: Fri Dec 20 2024 - 06:10:58 EST
…
> +++ b/net/dsa/dsa.c
> @@ -1561,6 +1561,17 @@ void dsa_unregister_switch(struct dsa_switch *ds)
> }
> EXPORT_SYMBOL_GPL(dsa_unregister_switch);
>
> +static void dsa_conduit_ethtool_shutdown(struct net_device *dev)
> +{
> + struct dsa_port *cpu_dp = dev->dsa_ptr;
I suggest to assign this local variable only after the subsequent check.
> +
> + if (netif_is_lag_master(dev))
> + return;
> +
> + dev->ethtool_ops = cpu_dp->orig_ethtool_ops;
> + cpu_dp->orig_ethtool_ops = NULL;
> +}
…
Regards,
Markus