Skip to content

Commit 3e64cf7

Browse files
camelia-groza-NXPdavem330
authored andcommitted
net: phy: phy driver features are mandatory
Since phy driver features became a link_mode bitmap, phy drivers that don't have a list of features configured will cause the kernel to crash when probed. Prevent the phy driver from registering if the features field is missing. Fixes: 719655a ("net: phy: Replace phy driver features u32 with link_mode bitmap") Reported-by: Scott Wood <oss@buserror.net> Signed-off-by: Camelia Groza <camelia.groza@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7afa81c commit 3e64cf7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

drivers/net/phy/phy_device.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,6 +2255,11 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner)
22552255
{
22562256
int retval;
22572257

2258+
if (WARN_ON(!new_driver->features)) {
2259+
pr_err("%s: Driver features are missing\n", new_driver->name);
2260+
return -EINVAL;
2261+
}
2262+
22582263
new_driver->mdiodrv.flags |= MDIO_DEVICE_IS_PHY;
22592264
new_driver->mdiodrv.driver.name = new_driver->name;
22602265
new_driver->mdiodrv.driver.bus = &mdio_bus_type;

include/linux/phy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,8 @@ struct phy_device {
469469
* only works for PHYs with IDs which match this field
470470
* name: The friendly name of this PHY type
471471
* phy_id_mask: Defines the important bits of the phy_id
472-
* features: A list of features (speed, duplex, etc) supported
473-
* by this PHY
472+
* features: A mandatory list of features (speed, duplex, etc)
473+
* supported by this PHY
474474
* flags: A bitfield defining certain other features this PHY
475475
* supports (like interrupts)
476476
*

0 commit comments

Comments
 (0)