diff options
author | Oleksij Rempel <o.rempel@pengutronix.de> | 2025-06-26 12:37:31 +0200 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2025-07-01 12:42:51 +0200 |
commit | c22f056e49d905d54a0203a32e344dc422766e38 (patch) | |
tree | df86e02d083aa18b5158a8c837cb2f54b60dc987 /net/lapb/lapb_in.c | |
parent | 8f240030794ca027fa669b447c0f27ffd8ae72d5 (diff) |
net: usb: lan78xx: fix possible NULL pointer dereference in lan78xx_phy_init()
If no PHY device is found (e.g., for LAN7801 in fixed-link mode),
lan78xx_phy_init() may proceed to dereference a NULL phydev pointer,
leading to a crash.
Update the logic to perform MAC configuration first, then check for the presence
of a PHY. For the fixed-link case, set up the fixed link and return early,
bypassing any code that assumes a valid phydev pointer.
It is safe to move lan78xx_mac_prepare_for_phy() earlier because this function
only uses information from dev->interface, which is configured by
lan78xx_get_phy() beforehand. The function does not access phydev or any data
set up by later steps.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Fixes: e110bc825897 ("net: usb: lan78xx: Convert to PHYLINK for improved PHY and MAC management")
Link: https://patch.msgid.link/20250626103731.3986545-1-o.rempel@pengutronix.de
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/lapb/lapb_in.c')
0 files changed, 0 insertions, 0 deletions