Re: [PATCH] net: dsa: mt7530: fix null pointer dereferencing in port5 setup

From: Andrew Lunn
Date: Sat Apr 04 2020 - 11:08:53 EST


On Sat, Apr 04, 2020 at 11:19:10AM +0800, Chuanhong Guo wrote:
> Hi!
>
> On Sat, Apr 4, 2020 at 2:09 AM René van Dorst <opensource@xxxxxxxxxx> wrote:
> >
> > Quoting Chuanhong Guo <gch981213@xxxxxxxxx>:
> >
> > Hi Chuanhong,
> >
> > > The 2nd gmac of mediatek soc ethernet may not be connected to a PHY
> > > and a phy-handle isn't always available.
> > > Unfortunately, mt7530 dsa driver assumes that the 2nd gmac is always
> > > connected to switch port 5 and setup mt7530 according to phy address
> > > of 2nd gmac node, causing null pointer dereferencing when phy-handle
> > > isn't defined in dts.
> >
> > MT7530 tries to detect if 2nd GMAC is using a phy with phy-address 0 or 4.
>
> What if the 2nd GMAC connects to an external PHY on address 0 on a
> different mdio-bus?

In general, you using a phy-handle to cover such a situation. If there
is a phy-handle, just use it.

Andrew