Commit 32fa4366 authored by Nikita Kiryushin's avatar Nikita Kiryushin Committed by Paolo Abeni

net: phy: fix phy_read_poll_timeout argument type in genphy_loopback

read_poll_timeout inside phy_read_poll_timeout can set val negative
in some cases (for example, __mdiobus_read inside phy_read can return
-EOPNOTSUPP).

Supposedly, commit 4ec73295 ("net: phylib: fix phy_read*_poll_timeout()")
should fix problems with wrong-signed vals, but I do not see how
as val is sent to phy_read as is and __val = phy_read (not val)
is checked for sign.

Change val type for signed to allow better error handling as done in other
phy_read_poll_timeout callers. This will not fix any error handling
by itself, but allows, for example, to modify cond with appropriate
sign check or check resulting val separately.

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

Fixes: 014068dc ("net: phy: genphy_loopback: add link speed configuration")
Signed-off-by: default avatarNikita Kiryushin <kiryushin@ancud.ru>
Reviewed-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/20240315175052.8049-1-kiryushin@ancud.ruSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 9474c62a
......@@ -2831,8 +2831,8 @@ EXPORT_SYMBOL(genphy_resume);
int genphy_loopback(struct phy_device *phydev, bool enable)
{
if (enable) {
u16 val, ctl = BMCR_LOOPBACK;
int ret;
u16 ctl = BMCR_LOOPBACK;
int ret, val;
ctl |= mii_bmcr_encode_fixed(phydev->speed, phydev->duplex);
......
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