* [PATCH][next] net: dsa: ksz: Make reg_mib_cnt a u8 as it never exceeds 255
@ 2021-04-28 12:00 Colin King
2021-04-28 15:50 ` Florian Fainelli
2021-04-28 21:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2021-04-28 12:00 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vivien Didelot,
Florian Fainelli, Vladimir Oltean, David S . Miller,
Jakub Kicinski, Marek Vasut, Tristram Ha, netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently the for-loop in ksz8_port_init_cnt is causing a static
analysis infinite loop warning with the comparison of
mib->cnt_ptr < dev->reg_mib_cnt. This occurs because mib->cnt_ptr
is a u8 and dev->reg_mib_cnt is an int and the analyzer determines
that mib->cnt_ptr potentially can wrap around to zero if the value
in dev->reg_mib_cnt is > 255. However, this value is never this
large, it is always less than 256 so make reg_mib_cnt a u8.
Addresses-Coverity: ("Infinite loop")
Fixes: e66f840c08a2 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/dsa/microchip/ksz_common.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index e0bbdca64375..2e6bfd333f50 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -69,7 +69,7 @@ struct ksz_device {
int cpu_ports; /* port bitmap can be cpu port */
int phy_port_cnt;
int port_cnt;
- int reg_mib_cnt;
+ u8 reg_mib_cnt;
int mib_cnt;
const struct mib_names *mib_names;
phy_interface_t compat_interface;
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][next] net: dsa: ksz: Make reg_mib_cnt a u8 as it never exceeds 255
2021-04-28 12:00 [PATCH][next] net: dsa: ksz: Make reg_mib_cnt a u8 as it never exceeds 255 Colin King
@ 2021-04-28 15:50 ` Florian Fainelli
2021-04-28 21:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2021-04-28 15:50 UTC (permalink / raw)
To: Colin King, Woojung Huh, UNGLinuxDriver, Andrew Lunn,
Vivien Didelot, Vladimir Oltean, David S . Miller,
Jakub Kicinski, Marek Vasut, Tristram Ha, netdev
Cc: kernel-janitors, linux-kernel
On 4/28/2021 5:00 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the for-loop in ksz8_port_init_cnt is causing a static
> analysis infinite loop warning with the comparison of
> mib->cnt_ptr < dev->reg_mib_cnt. This occurs because mib->cnt_ptr
> is a u8 and dev->reg_mib_cnt is an int and the analyzer determines
> that mib->cnt_ptr potentially can wrap around to zero if the value
> in dev->reg_mib_cnt is > 255. However, this value is never this
> large, it is always less than 256 so make reg_mib_cnt a u8.
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] net: dsa: ksz: Make reg_mib_cnt a u8 as it never exceeds 255
2021-04-28 12:00 [PATCH][next] net: dsa: ksz: Make reg_mib_cnt a u8 as it never exceeds 255 Colin King
2021-04-28 15:50 ` Florian Fainelli
@ 2021-04-28 21:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-04-28 21:10 UTC (permalink / raw)
To: Colin King
Cc: woojung.huh, UNGLinuxDriver, andrew, vivien.didelot, f.fainelli,
olteanv, davem, kuba, marex, Tristram.Ha, netdev,
kernel-janitors, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
On Wed, 28 Apr 2021 13:00:10 +0100 you wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the for-loop in ksz8_port_init_cnt is causing a static
> analysis infinite loop warning with the comparison of
> mib->cnt_ptr < dev->reg_mib_cnt. This occurs because mib->cnt_ptr
> is a u8 and dev->reg_mib_cnt is an int and the analyzer determines
> that mib->cnt_ptr potentially can wrap around to zero if the value
> in dev->reg_mib_cnt is > 255. However, this value is never this
> large, it is always less than 256 so make reg_mib_cnt a u8.
>
> [...]
Here is the summary with links:
- [next] net: dsa: ksz: Make reg_mib_cnt a u8 as it never exceeds 255
https://git.kernel.org/netdev/net-next/c/12c2bb96c3f1
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-04-28 21:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28 12:00 [PATCH][next] net: dsa: ksz: Make reg_mib_cnt a u8 as it never exceeds 255 Colin King
2021-04-28 15:50 ` Florian Fainelli
2021-04-28 21:10 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.