Skip to content

Commit 12c2bb9

Browse files
Colin Ian Kingkuba-moo
authored andcommitted
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: e66f840 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9be02dd commit 12c2bb9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/dsa/microchip/ksz_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct ksz_device {
6969
int cpu_ports; /* port bitmap can be cpu port */
7070
int phy_port_cnt;
7171
int port_cnt;
72-
int reg_mib_cnt;
72+
u8 reg_mib_cnt;
7373
int mib_cnt;
7474
const struct mib_names *mib_names;
7575
phy_interface_t compat_interface;

0 commit comments

Comments
 (0)