Skip to content

Commit 32fa436

Browse files
nkiryushinPaolo Abeni
authored andcommitted
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 4ec7329 ("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: 014068d ("net: phy: genphy_loopback: add link speed configuration") Signed-off-by: Nikita Kiryushin <[email protected]> Reviewed-by: Russell King (Oracle) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 9474c62 commit 32fa436

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/phy/phy_device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,8 +2831,8 @@ EXPORT_SYMBOL(genphy_resume);
28312831
int genphy_loopback(struct phy_device *phydev, bool enable)
28322832
{
28332833
if (enable) {
2834-
u16 val, ctl = BMCR_LOOPBACK;
2835-
int ret;
2834+
u16 ctl = BMCR_LOOPBACK;
2835+
int ret, val;
28362836

28372837
ctl |= mii_bmcr_encode_fixed(phydev->speed, phydev->duplex);
28382838

0 commit comments

Comments
 (0)