Re: net: phy: realtek: regression, kernel null pointer dereference

From: Heiner Kallweit
Date: Sat May 11 2019 - 10:58:33 EST


On 11.05.2019 16:46, Vicente Bergas wrote:
> On Friday, May 10, 2019 10:28:06 PM CEST, Heiner Kallweit wrote:
>> On 10.05.2019 17:05, Vicente Bergas wrote:
>>> Hello,
>>> there is a regression on linux v5.1-9573-gb970afcfcabd with a kernel null
>>> pointer dereference.
>>> The issue is the commit f81dadbcf7fd067baf184b63c179fc392bdb226e
>>> Ânet: phy: realtek: Add rtl8211e rx/tx delays config ...
>> The page operation callbacks are missing in the RTL8211E driver.
>> I just submitted a fix adding these callbacks to few Realtek PHY drivers
>> including RTl8211E. This should fix the issue.
>
> Hello Heiner,
> just tried your patch and indeed the NPE is gone. But still no network...
> The MAC <-> PHY link was working before, so, maybe the rgmii delays are not
> correctly configured.

That's a question to the author of the original patch. My patch was just
meant to fix the NPE. In which configuration are you using the RTL8211E?
As a standalone PHY (with which MAC/driver?) or is it the integrated PHY
in a member of the RTL8168 family?

Serge: The issue with the NPE gave a hint already that you didn't test your
patch. Was your patch based on an actual issue on some board and did you
test it? We may have to consider reverting the patch.

> With this change it is back to working:
> --- a/drivers/net/phy/realtek.c
> +++ b/drivers/net/phy/realtek.c
> @@ -300,7 +300,6 @@
> ÂÂÂÂ}, {
> ÂÂÂÂÂÂÂ PHY_ID_MATCH_EXACT(0x001cc915),
> ÂÂÂÂÂÂÂ .nameÂÂÂÂÂÂÂ = "RTL8211E Gigabit Ethernet",
> -ÂÂÂÂÂÂÂ .config_initÂÂÂ = &rtl8211e_config_init,
> ÂÂÂÂÂÂÂ .ack_interruptÂÂÂ = &rtl821x_ack_interrupt,
> ÂÂÂÂÂÂÂ .config_intrÂÂÂ = &rtl8211e_config_intr,
> ÂÂÂÂÂÂÂ .suspendÂÂÂ = genphy_suspend,
> That is basically reverting the patch.
>
> Regards,
> ÂVicenÃ.
>
>> Nevertheless your proposed patch looks good to me, just one small change
>> would be needed and it should be splitted.
>>
>> The change to phy-core I would consider a fix and it should be fine to
>> submit it to net (net-next is closed currently).
>>
>> Adding the warning to the Realtek driver is fine, but this would be
>> something for net-next once it's open again.
>>
>>> Regards,
>>> ÂVicenÃ.
>>>
>> Heiner
>>
>>> --- a/drivers/net/phy/phy-core.c
>>> +++ b/drivers/net/phy/phy-core.c
>>> @@ -648,11 +648,17 @@
>>>
>>> static int __phy_read_page(struct phy_device *phydev)
>>> { ...
>>
>> Here phydev_warn() should be used.
>>
>>> +ÂÂÂÂÂÂÂ return 0;
>>> +ÂÂÂ }
>>>
>>> ÂÂÂ ret = phy_write(phydev, RTL821x_EXT_PAGE_SELECT, 0xa4);
>>> ÂÂÂ if (ret)
>
>