* [PATCH][next][V2] net: pcs: xpcs: Fix a less than zero u16 comparison error
@ 2021-06-15 13:52 Colin King
2021-06-15 14:01 ` Vladimir Oltean
2021-06-17 18:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2021-06-15 13:52 UTC (permalink / raw)
To: Vladimir Oltean, Andrew Lunn, Heiner Kallweit, Russell King,
David S . Miller, Jakub Kicinski, netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently the check for the u16 variable val being less than zero is
always false because val is unsigned. Fix this by using the int
variable for the assignment and less than zero check.
Addresses-Coverity: ("Unsigned compared against 0")
Fixes: f7380bba42fd ("net: pcs: xpcs: add support for NXP SJA1110")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
V2: Fix typo in subject and align the following 2 lines after the
val = ret & ... assignment. Thanks to Vladimir Oltean for spotting
these.
---
drivers/net/pcs/pcs-xpcs-nxp.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/pcs/pcs-xpcs-nxp.c b/drivers/net/pcs/pcs-xpcs-nxp.c
index de99c37cf2ae..984c9f7f16a8 100644
--- a/drivers/net/pcs/pcs-xpcs-nxp.c
+++ b/drivers/net/pcs/pcs-xpcs-nxp.c
@@ -152,13 +152,13 @@ static int nxp_sja1110_pma_config(struct dw_xpcs *xpcs,
/* Enable TX and RX PLLs and circuits.
* Release reset of PMA to enable data flow to/from PCS.
*/
- val = xpcs_read(xpcs, MDIO_MMD_VEND2, SJA1110_POWERDOWN_ENABLE);
- if (val < 0)
- return val;
+ ret = xpcs_read(xpcs, MDIO_MMD_VEND2, SJA1110_POWERDOWN_ENABLE);
+ if (ret < 0)
+ return ret;
- val &= ~(SJA1110_TXPLL_PD | SJA1110_TXPD | SJA1110_RXCH_PD |
- SJA1110_RXBIAS_PD | SJA1110_RESET_SER_EN |
- SJA1110_RESET_SER | SJA1110_RESET_DES);
+ val = ret & ~(SJA1110_TXPLL_PD | SJA1110_TXPD | SJA1110_RXCH_PD |
+ SJA1110_RXBIAS_PD | SJA1110_RESET_SER_EN |
+ SJA1110_RESET_SER | SJA1110_RESET_DES);
val |= SJA1110_RXPKDETEN | SJA1110_RCVEN;
ret = xpcs_write(xpcs, MDIO_MMD_VEND2, SJA1110_POWERDOWN_ENABLE, val);
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][next][V2] net: pcs: xpcs: Fix a less than zero u16 comparison error
2021-06-15 13:52 [PATCH][next][V2] net: pcs: xpcs: Fix a less than zero u16 comparison error Colin King
@ 2021-06-15 14:01 ` Vladimir Oltean
2021-06-17 18:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Oltean @ 2021-06-15 14:01 UTC (permalink / raw)
To: Colin King
Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
Jakub Kicinski, netdev, kernel-janitors, linux-kernel
On Tue, Jun 15, 2021 at 02:52:53PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the check for the u16 variable val being less than zero is
> always false because val is unsigned. Fix this by using the int
> variable for the assignment and less than zero check.
>
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: f7380bba42fd ("net: pcs: xpcs: add support for NXP SJA1110")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> V2: Fix typo in subject and align the following 2 lines after the
> val = ret & ... assignment. Thanks to Vladimir Oltean for spotting
> these.
> ---
Thanks.
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next][V2] net: pcs: xpcs: Fix a less than zero u16 comparison error
2021-06-15 13:52 [PATCH][next][V2] net: pcs: xpcs: Fix a less than zero u16 comparison error Colin King
2021-06-15 14:01 ` Vladimir Oltean
@ 2021-06-17 18:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-17 18:20 UTC (permalink / raw)
To: Colin King
Cc: olteanv, andrew, hkallweit1, linux, davem, kuba, netdev,
kernel-janitors, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
On Tue, 15 Jun 2021 14:52:53 +0100 you wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the check for the u16 variable val being less than zero is
> always false because val is unsigned. Fix this by using the int
> variable for the assignment and less than zero check.
>
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: f7380bba42fd ("net: pcs: xpcs: add support for NXP SJA1110")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> [...]
Here is the summary with links:
- [next,V2] net: pcs: xpcs: Fix a less than zero u16 comparison error
https://git.kernel.org/netdev/net-next/c/d356dbe23f60
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] 3+ messages in thread
end of thread, other threads:[~2021-06-17 18:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 13:52 [PATCH][next][V2] net: pcs: xpcs: Fix a less than zero u16 comparison error Colin King
2021-06-15 14:01 ` Vladimir Oltean
2021-06-17 18:20 ` 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).