]> git.baikalelectronics.ru Git - kernel.git/commit
net: mdio: validate parameter addr in mdiobus_get_phy()
authorHeiner Kallweit <hkallweit1@gmail.com>
Sun, 15 Jan 2023 10:54:06 +0000 (11:54 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Feb 2023 06:52:38 +0000 (07:52 +0100)
commitd2457018c948e94ca13a49c6521f64630e633cec
tree932ba1c01b0bba7f63871a651c77374b6e86054c
parent73da3a86719d92f2d7b755816819016bb9a61027
net: mdio: validate parameter addr in mdiobus_get_phy()

[ Upstream commit 867dbe784c5010a466f00a7d1467c1c5ea569c75 ]

The caller may pass any value as addr, what may result in an out-of-bounds
access to array mdio_map. One existing case is stmmac_init_phy() that
may pass -1 as addr. Therefore validate addr before using it.

Fixes: 4c73cde247d0 ("phy: Add API for {un}registering an mdio device to a bus.")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/cdf664ea-3312-e915-73f8-021678d08887@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/phy/mdio_bus.c