summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorCamelia Groza <camelia.groza@nxp.com>2019-01-17 14:22:36 +0200
committerDavid S. Miller <davem@davemloft.net>2019-01-19 10:03:08 -0800
commit3e64cf7a435ed0500e3adaa8aada2272d3ae8abc (patch)
treee7999c0a0af25273008032ee1b13d1ad64f20aee /drivers
parent7afa81c55fca0cad589722cb4bce698b4803b0e1 (diff)
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: 719655a14971 ("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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/phy/phy_device.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index bf3ce48a1e5d..46c86725a693 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2255,6 +2255,11 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner)
{
int retval;
+ if (WARN_ON(!new_driver->features)) {
+ pr_err("%s: Driver features are missing\n", new_driver->name);
+ return -EINVAL;
+ }
+
new_driver->mdiodrv.flags |= MDIO_DEVICE_IS_PHY;
new_driver->mdiodrv.driver.name = new_driver->name;
new_driver->mdiodrv.driver.bus = &mdio_bus_type;