Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: phy: micrel: always set shared->phydev for LAN8814

Currently, during the LAN8814 PTP probe shared->phydev is only set if PTP
clock gets actually set, otherwise the function will return before setting
it.

This is an issue as shared->phydev is unconditionally being used when IRQ
is being handled, especially in lan8814_gpio_process_cap and since it was
not set it will cause a NULL pointer exception and crash the kernel.

So, simply always set shared->phydev to avoid the NULL pointer exception.

Fixes: b3f1a08fcf0d ("net: phy: micrel: Add support for PTP_PF_EXTTS for lan8814")
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Link: https://patch.msgid.link/20251021132034.983936-1-robert.marko@sartura.hr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Robert Marko and committed by
Jakub Kicinski
399d1093 f7c877e7

+2 -2
+2 -2
drivers/net/phy/micrel.c
··· 4262 4262 { 4263 4263 struct lan8814_shared_priv *shared = phy_package_get_priv(phydev); 4264 4264 4265 + shared->phydev = phydev; 4266 + 4265 4267 /* Initialise shared lock for clock*/ 4266 4268 mutex_init(&shared->shared_lock); 4267 4269 ··· 4318 4316 return 0; 4319 4317 4320 4318 phydev_dbg(phydev, "successfully registered ptp clock\n"); 4321 - 4322 - shared->phydev = phydev; 4323 4319 4324 4320 /* The EP.4 is shared between all the PHYs in the package and also it 4325 4321 * can be accessed by any of the PHYs