[PATCH] net: dsa: add return value check of genphy_read_status()

From: Alexandra Diupina
Date: Thu Mar 14 2024 - 02:36:52 EST


Need to check return value of genphy_read_status(),
because higher in the call hierarchy is the
dsa_register_switch() function,
which is used in various drivers.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 33615367f378 ("net: dsa: Support internal phy on 'cpu' port")
Signed-off-by: Alexandra Diupina <adiupina@xxxxxxxxxxxxx>
---
net/dsa/port.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/dsa/port.c b/net/dsa/port.c
index c42dac87671b..c411f30bb5f6 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -1765,7 +1765,9 @@ static int dsa_shared_port_fixed_link_register_of(struct dsa_port *dp)
mode = PHY_INTERFACE_MODE_NA;
phydev->interface = mode;

- genphy_read_status(phydev);
+ err = genphy_read_status(phydev);
+ if (err)
+ return err;

if (ds->ops->adjust_link)
ds->ops->adjust_link(ds, port, phydev);
--
2.30.2