* [PATCH][next] net: phy: realtek: net: Fix less than zero comparison of a u16
@ 2021-06-09 17:17 Colin King
2021-06-09 22:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-06-09 17:17 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
Jakub Kicinski, Joakim Zhang, netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The comparisons of the u16 values priv->phycr1 and priv->phycr2 to less
than zero always false because they are unsigned. Fix this by using an
int for the assignment and less than zero check.
Addresses-Coverity: ("Unsigned compared against 0")
Fixes: 0a4355c2b7f8 ("net: phy: realtek: add dt property to disable CLKOUT clock")
Fixes: d90db36a9e74 ("net: phy: realtek: add dt property to enable ALDPS mode")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/phy/realtek.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 1b844a06fe72..11be60333fa8 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -94,24 +94,25 @@ static int rtl821x_probe(struct phy_device *phydev)
{
struct device *dev = &phydev->mdio.dev;
struct rtl821x_priv *priv;
+ int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
- priv->phycr1 = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR1);
- if (priv->phycr1 < 0)
- return priv->phycr1;
+ ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR1);
+ if (ret < 0)
+ return ret;
- priv->phycr1 &= (RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF);
+ priv->phycr1 = ret & (RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF);
if (of_property_read_bool(dev->of_node, "realtek,aldps-enable"))
priv->phycr1 |= RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF;
- priv->phycr2 = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR2);
- if (priv->phycr2 < 0)
- return priv->phycr2;
+ ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR2);
+ if (ret < 0)
+ return ret;
- priv->phycr2 &= RTL8211F_CLKOUT_EN;
+ priv->phycr2 = ret & RTL8211F_CLKOUT_EN;
if (of_property_read_bool(dev->of_node, "realtek,clkout-disable"))
priv->phycr2 &= ~RTL8211F_CLKOUT_EN;
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][next] net: phy: realtek: net: Fix less than zero comparison of a u16
2021-06-09 17:17 [PATCH][next] net: phy: realtek: net: Fix less than zero comparison of a u16 Colin King
@ 2021-06-09 22:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-09 22:40 UTC (permalink / raw)
To: Colin King
Cc: andrew, hkallweit1, linux, davem, kuba, qiangqing.zhang, netdev,
kernel-janitors, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
On Wed, 9 Jun 2021 18:17:48 +0100 you wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The comparisons of the u16 values priv->phycr1 and priv->phycr2 to less
> than zero always false because they are unsigned. Fix this by using an
> int for the assignment and less than zero check.
>
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: 0a4355c2b7f8 ("net: phy: realtek: add dt property to disable CLKOUT clock")
> Fixes: d90db36a9e74 ("net: phy: realtek: add dt property to enable ALDPS mode")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> [...]
Here is the summary with links:
- [next] net: phy: realtek: net: Fix less than zero comparison of a u16
https://git.kernel.org/netdev/net-next/c/f25247d88708
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-09 22:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 17:17 [PATCH][next] net: phy: realtek: net: Fix less than zero comparison of a u16 Colin King
2021-06-09 22:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).