]> git.baikalelectronics.ru Git - kernel.git/commit
net: dsa: ksz: Make reg_mib_cnt a u8 as it never exceeds 255
authorColin Ian King <colin.king@canonical.com>
Wed, 28 Apr 2021 12:00:10 +0000 (13:00 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 28 Apr 2021 20:56:27 +0000 (13:56 -0700)
commita1b95680d99b3ff97a1d0eb8f2edb2d7cf76f44c
tree749bb9a0ad505f6518a61830d9c1d51ec3eb6ecd
parent0d47fc92b20ed0ff3ef3470c220cc9651b2dceda
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: dae88cfc78e9 ("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>
drivers/net/dsa/microchip/ksz_common.h