Hi Florian,
Florian Fainelli <[email protected]> writes:
> It is perfectly possible to have non zero indexed switches being present
> in a DSA switch tree, in such a case, we will be deferencing a NULL
> pointer while dsa_cpu_port_ethtool_{setup,restore}. Be more defensive
> and ensure that dst->ds[0] is valid before doing anything with it.
>
> Fixes: 0c73c523cf73 ("net: dsa: Initialize CPU port ethtool ops per tree")
> Signed-off-by: Florian Fainelli <[email protected]>
Reviewed-by: Vivien Didelot <[email protected]>
The patch is correct since we are already using dst->ds[0] here.
But we should stop using that and use dst->cpu_switch instead, because
the switch with ID 0 won't necessary be the CPU switch. Now that the
Ethernet switch chips are true Linux devices, they are registered in
order depending on their bus/address. So in a setup like this:
,--MDIO--@4--------@2--
| | |
[CPU] <-> [swA] <-> [swB]
swB will have index 0 and swA will have index 1. Please correct me if
I'm wrong.
Thanks,
Vivien