net: phy: fix phy_read_poll_timeout argument type in genphy_loopback
Subsystems (3)
PATCH 1/1 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 4ec732951702 ("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.
--- drivers/net/phy/phy_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/phy_device.c +2 -2
@@ -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);
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerQuoted 14 lines · On Thu, 14 Mar 2024 14:15:37 +0300 Nikita Kiryushin wrote:
read_poll_timeoutinsidephy_read_poll_timeoutcan set val negative in some cases (for example,__mdiobus_readinsidephy_readcan return-EOPNOTSUPP).Supposedly, commit
4ec732951702("net: phylib: fix phy_read*_poll_timeout()") should fix problems with wrong-signed vals, but I do not see how as val is sent tophy_readas 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_timeoutcallers. 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.
Quoted 4 lines
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes 014068dcb5b1 ("net: phy: genphy_loopback: add link speed configuration")Signed-off-by Nikita Kiryushin <[email protected]>
Please use git send email, the patch is mangled.
Signature · 1 line
pw-bot: cr
PATCH 1/1 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 4ec732951702 ("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.
--- drivers/net/phy/phy_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/phy_device.c +2 -2
@@ -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);
Signature · 1 line
2.34.1
Quoted 14 lines · Nikita Kiryushin
read_poll_timeoutinsidephy_read_poll_timeoutcan set val negative in some cases (for example,__mdiobus_readinsidephy_readcan return-EOPNOTSUPP).Supposedly, commit
4ec732951702("net: phylib: fix phy_read*_poll_timeout()") should fix problems with wrong-signed vals, but I do not see how as val is sent tophy_readas 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_timeoutcallers. 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.
Quoted 4 lines
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes 014068dcb5b1 ("net: phy: genphy_loopback: add link speed configuration")Signed-off-by Nikita Kiryushin <[email protected]>
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 10 lines · On Fri, 15 Mar 2024 20:50:52 +0300 you wrote:
read_poll_timeoutinsidephy_read_poll_timeoutcan set val negative in some cases (for example,__mdiobus_readinsidephy_readcan return-EOPNOTSUPP).Supposedly, commit
4ec732951702("net: phylib: fix phy_read*_poll_timeout()") should fix problems with wrong-signed vals, but I do not see how as val is sent tophy_readas is and__val=phy_read(not val) is checked for sign.[...]
Here is the summary with links:
- [net] net: phy: fix phy_read_poll_timeout argument type in genphy_loopback
https://git.kernel.org/netdev/net/c/32fa4366cc4d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html