Commit 2b12d51c authored by Russell King (Oracle)'s avatar Russell King (Oracle) Committed by David S. Miller
Browse files

net: phylib: ensure phy device drivers do not match by DT

PHYLIB device drivers must match by either numerical PHY ID or by their
.match_phy_device method. Matching by DT is not permitted.

Link: https://lore.kernel.org/r/2b1dc053-8c9a-e3e4-b450-eecdfca3fe16@gmail.com


Tested-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 94114d90
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -3146,6 +3146,16 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner)
		return -EINVAL;
	}

	/* PHYLIB device drivers must not match using a DT compatible table
	 * as this bypasses our checks that the mdiodev that is being matched
	 * is backed by a struct phy_device. If such a case happens, we will
	 * make out-of-bounds accesses and lockup in phydev->lock.
	 */
	if (WARN(new_driver->mdiodrv.driver.of_match_table,
		 "%s: driver must not provide a DT match table\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;