Re: [PATCH] net: phy: adin1100: Fix nullptr exception for phy interrupts

Russell King (Oracle)
2024-01-19T09:56:49Z

On Fri, Jan 19, 2024 at 04:05:29AM +0100, Andre Werner wrote:
> On Thu, 18 Jan 2024, Russell King (Oracle) wrote:
>
> > In addition to Andrew's comments:
> >
> > On Thu, Jan 18, 2024 at 11:43:41AM +0100, Andre Werner wrote:
> > > +static int adin_config_intr(struct phy_device *phydev)
> > > +{
> > > + int ret, regval;
> > > +
> > > + ret = adin_phy_ack_intr(phydev);
> > > +
> > > + if (ret)
> > > + return ret;
> > > +
> > > + regval = phy_read_mmd(phydev, MDIO_MMD_VEND2, ADIN_PHY_SUBSYS_IRQ_MASK);
> > > + if (regval < 0)
> > > + return regval;
> > > +
> > > + if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
> > > + regval |= ADIN_LINK_STAT_CHNG_IRQ_EN;
> > > + else
> > > + regval &= ~ADIN_LINK_STAT_CHNG_IRQ_EN;
> > > +
> > > + ret = phy_write_mmd(phydev, MDIO_MMD_VEND2,
> > > + ADIN_PHY_SUBSYS_IRQ_MASK,
> > > + regval);
> > > + return ret;
> >
> > u16 irq_mask;
> >
> > if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
> > irq_mask = ADIN_LINK_STAT_CHNG_IRQ_EN;
> > else
> > irq_mask = 0;
>
> Unfortunately, I can not do this, because that phy ask for read-modify-write access to
> registers and some bits in this register are already set after reset and
> should not being modified.
>
> >
> > return phy_modify_mmd(phydev, MDIO_MMD_VEND2,
> > ADIN_PHY_SUBSYS_IRQ_MASK,
> > ADIN_LINK_STAT_CHNG_IRQ_EN, irq_mask);

So you don't understand... phy_modify_mmd() will do a read-modify-write
and because the mask passed is ADIN_LINK_STAT_CHNG_IRQ_EN, this is the
_only_ bit that will be affected.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!