aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2021-04-28 13:00:10 +0100
committerJakub Kicinski <kuba@kernel.org>2021-04-28 13:56:27 -0700
commit12c2bb96c3f1916624d671904430b7714b48dd71 (patch)
tree749bb9a0ad505f6518a61830d9c1d51ec3eb6ecd /drivers
parentnet/sched: act_ct: Remove redundant ct get and check (diff)
downloadlinux-dev-12c2bb96c3f1916624d671904430b7714b48dd71.tar.xz
linux-dev-12c2bb96c3f1916624d671904430b7714b48dd71.zip
net: dsa: ksz: Make reg_mib_cnt a u8 as it never exceeds 255
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> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Link: https://lore.kernel.org/r/20210428120010.337959-1-colin.king@canonical.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/dsa/microchip/ksz_common.h2
1 files changed, 1 insertions, 1 deletions
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;