* [PATCH net-next] net: mdio: warn once if addr parameter is invalid in mdiobus_get_phy()
@ 2023-01-20 22:18 Heiner Kallweit
2023-01-24 2:17 ` Andrew Lunn
2023-01-24 5:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Heiner Kallweit @ 2023-01-20 22:18 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, David Miller,
Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: netdev@vger.kernel.org
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: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/mdio_bus.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 16e021b47..ed66a1986 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -108,9 +108,10 @@ EXPORT_SYMBOL(mdiobus_unregister_device);
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;
- if (addr < 0 || addr >= ARRAY_SIZE(bus->mdio_map))
+ if (WARN_ONCE(!addr_valid, "addr %d out of range\n", addr))
return NULL;
mdiodev = bus->mdio_map[addr];
--
2.39.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: mdio: warn once if addr parameter is invalid in mdiobus_get_phy()
2023-01-20 22:18 [PATCH net-next] net: mdio: warn once if addr parameter is invalid in mdiobus_get_phy() Heiner Kallweit
@ 2023-01-24 2:17 ` Andrew Lunn
2023-01-24 5:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2023-01-24 2:17 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Russell King - ARM Linux, David Miller, Jakub Kicinski,
Paolo Abeni, Eric Dumazet, netdev@vger.kernel.org
On Fri, Jan 20, 2023 at 11:18:32PM +0100, Heiner Kallweit wrote:
> 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: Paolo Abeni <pabeni@redhat.com>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: mdio: warn once if addr parameter is invalid in mdiobus_get_phy()
2023-01-20 22:18 [PATCH net-next] net: mdio: warn once if addr parameter is invalid in mdiobus_get_phy() Heiner Kallweit
2023-01-24 2:17 ` Andrew Lunn
@ 2023-01-24 5:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-24 5:40 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: andrew, linux, davem, kuba, pabeni, edumazet, netdev
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 20 Jan 2023 23:18:32 +0100 you wrote:
> 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: Paolo Abeni <pabeni@redhat.com>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/net/phy/mdio_bus.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Here is the summary with links:
- [net-next] net: mdio: warn once if addr parameter is invalid in mdiobus_get_phy()
https://git.kernel.org/netdev/net-next/c/8a8b70b3f2cf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-24 5:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-20 22:18 [PATCH net-next] net: mdio: warn once if addr parameter is invalid in mdiobus_get_phy() Heiner Kallweit
2023-01-24 2:17 ` Andrew Lunn
2023-01-24 5:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).