Commit 8a8b70b3 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Jakub Kicinski

net: mdio: warn once if addr parameter is invalid in mdiobus_get_phy()

If mdiobus_get_phy() is called with an invalid addr parameter, then the
caller has a bug. Print a call trace to help identifying the caller.
Suggested-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/daec3f08-6192-ba79-f74b-5beb436cab6c@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 62be6939
...@@ -109,9 +109,10 @@ EXPORT_SYMBOL(mdiobus_unregister_device); ...@@ -109,9 +109,10 @@ EXPORT_SYMBOL(mdiobus_unregister_device);
struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr) struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr)
{ {
bool addr_valid = addr >= 0 && addr < ARRAY_SIZE(bus->mdio_map);
struct mdio_device *mdiodev; struct mdio_device *mdiodev;
if (addr < 0 || addr >= ARRAY_SIZE(bus->mdio_map)) if (WARN_ONCE(!addr_valid, "addr %d out of range\n", addr))
return NULL; return NULL;
mdiodev = bus->mdio_map[addr]; mdiodev = bus->mdio_map[addr];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment