Re: [PATCH net] net: phy: Fix possible NULL pointer dereference issues caused by phy_attached_info_irq

From: Kunwu Chan
Date: Mon Jan 15 2024 - 02:35:09 EST


On 2024/1/15 11:45, Andrew Lunn wrote:
Here, i would just skip the print and continue with the reset of the
function. The print is just useful information, its not a big problem
if its not printed. However, if this function does not complete, the
network interface is likely to be dead.
Thanks for the reminder.
The second part doesn't look so perfect, can we just print an empty string
when the irq_str is empty?

--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1886,7 +1886,7 @@ static int phylink_bringup_phy(struct phylink *pl,
struct phy_device *phy,
irq_str = phy_attached_info_irq(phy);
phylink_info(pl,
"PHY [%s] driver [%s] (irq=%s)\n",
- dev_name(&phy->mdio.dev), phy->drv->name, irq_str);
+ dev_name(&phy->mdio.dev), phy->drv->name, irq_str ?
irq_str : "");
kfree(irq_str);

That is O.K, or skip the whole phylink_info().

Andrew

Thanks, I will update it in v2 patch. Personal view, print a msg is good for debug.
--
Thanks,
Kunwu