mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
net: phy: phy_device: Prevent nullptr exceptions on ISR
[ Upstream commit 61c8187281
]
If phydev->irq is set unconditionally, check
for valid interrupt handler or fall back to polling mode to prevent
nullptr exceptions in interrupt service routine.
Signed-off-by: Andre Werner <andre.werner@systec-electronic.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20240129135734.18975-2-andre.werner@systec-electronic.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
2485beea14
commit
7a71f61ebf
1 changed files with 8 additions and 5 deletions
|
@ -1411,6 +1411,11 @@ int phy_sfp_probe(struct phy_device *phydev,
|
|||
}
|
||||
EXPORT_SYMBOL(phy_sfp_probe);
|
||||
|
||||
static bool phy_drv_supports_irq(struct phy_driver *phydrv)
|
||||
{
|
||||
return phydrv->config_intr && phydrv->handle_interrupt;
|
||||
}
|
||||
|
||||
/**
|
||||
* phy_attach_direct - attach a network device to a given PHY device pointer
|
||||
* @dev: network device to attach
|
||||
|
@ -1525,6 +1530,9 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
|
|||
if (phydev->dev_flags & PHY_F_NO_IRQ)
|
||||
phydev->irq = PHY_POLL;
|
||||
|
||||
if (!phy_drv_supports_irq(phydev->drv) && phy_interrupt_is_valid(phydev))
|
||||
phydev->irq = PHY_POLL;
|
||||
|
||||
/* Port is set to PORT_TP by default and the actual PHY driver will set
|
||||
* it to different value depending on the PHY configuration. If we have
|
||||
* the generic PHY driver we can't figure it out, thus set the old
|
||||
|
@ -2987,11 +2995,6 @@ s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev,
|
|||
}
|
||||
EXPORT_SYMBOL(phy_get_internal_delay);
|
||||
|
||||
static bool phy_drv_supports_irq(struct phy_driver *phydrv)
|
||||
{
|
||||
return phydrv->config_intr && phydrv->handle_interrupt;
|
||||
}
|
||||
|
||||
static int phy_led_set_brightness(struct led_classdev *led_cdev,
|
||||
enum led_brightness value)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue