Message ID | E1mYTMt-001hFb-Rl@rmk-PC.armlinux.org.uk (mailing list archive) |
---|---|
State | Accepted |
Commit | 94114d90037fe730bab5ea76d388bc294034fa39 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next] net: mdio: ensure the type of mdio devices match mdio drivers | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Single patches do not need cover letters |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 1 maintainers not CCed: linux@armlinux.org.uk |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | No Fixes tag |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 14 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | No static functions without inline keyword in header files |
Hello: This patch was applied to netdev/net-next.git (master) by David S. Miller <davem@davemloft.net>: On Thu, 07 Oct 2021 14:23:27 +0100 you wrote: > On the MDIO bus, we have PHYLIB devices and drivers, and we have non- > PHYLIB devices and drivers. PHYLIB devices are MDIO devices that are > wrapped with a struct phy_device. > > Trying to bind a MDIO device with a PHYLIB driver results in out-of- > bounds accesses as we attempt to access struct phy_device members. So, > let's prevent this by ensuring that the type of the MDIO device > (indicated by the MDIO_DEVICE_FLAG_PHY flag) matches the type of the > MDIO driver (indicated by the MDIO_DEVICE_IS_PHY flag.) > > [...] Here is the summary with links: - [net-next] net: mdio: ensure the type of mdio devices match mdio drivers https://git.kernel.org/netdev/net-next/c/94114d90037f You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index d8b68145f6b4..8c59eb6a2b68 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -961,8 +961,14 @@ EXPORT_SYMBOL_GPL(mdiobus_modify_changed); */ static int mdio_bus_match(struct device *dev, struct device_driver *drv) { + struct mdio_driver *mdiodrv = to_mdio_driver(drv); struct mdio_device *mdio = to_mdio_device(dev); + /* Both the driver and device must type-match */ + if (!(mdiodrv->mdiodrv.flags & MDIO_DEVICE_IS_PHY) != + !(mdio->flags & MDIO_DEVICE_FLAG_PHY)) + return 0; + if (of_driver_match_device(dev, drv)) return 1;