mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-05 19:31:57 -04:00
net: mdio: C22 is now optional, EOPNOTSUPP if not provided
[ Upstream commit b063b1924fd9bf0bc157cf644764dc2151d04ccc ]
When performing a C22 operation, check that the bus driver actually
provides the methods, and return -EOPNOTSUPP if not. C45 only busses
do exist, and in future their C22 methods will be NULL.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 0e629694126c ("net/mdiobus: Fix potential out-of-bounds read/write access")
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
da1f38bc18
commit
38c9d4f8e6
1 changed files with 8 additions and 2 deletions
|
|
@ -565,7 +565,10 @@ int __mdiobus_read(struct mii_bus *bus, int addr, u32 regnum)
|
|||
|
||||
WARN_ON_ONCE(!mutex_is_locked(&bus->mdio_lock));
|
||||
|
||||
retval = bus->read(bus, addr, regnum);
|
||||
if (bus->read)
|
||||
retval = bus->read(bus, addr, regnum);
|
||||
else
|
||||
retval = -EOPNOTSUPP;
|
||||
|
||||
trace_mdio_access(bus, 1, addr, regnum, retval, retval);
|
||||
|
||||
|
|
@ -590,7 +593,10 @@ int __mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val)
|
|||
|
||||
WARN_ON_ONCE(!mutex_is_locked(&bus->mdio_lock));
|
||||
|
||||
err = bus->write(bus, addr, regnum, val);
|
||||
if (bus->write)
|
||||
err = bus->write(bus, addr, regnum, val);
|
||||
else
|
||||
err = -EOPNOTSUPP;
|
||||
|
||||
trace_mdio_access(bus, 0, addr, regnum, val, err);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue