iwlegacy: ensure loop counter addr does not wrap and cause an infinite loop
authorColin Ian King <colin.king@canonical.com>
Sun, 26 Jan 2020 00:09:54 +0000 (00:09 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Feb 2020 07:36:58 +0000 (08:36 +0100)
commita2763f62baa47088f6252eab544b79d7f4e384aa
tree68a510dd9daccb7c1659d3f0ce9b54eedd245a09
parent034c5f26d2bf646389d33ea43d7bb0491525b67c
iwlegacy: ensure loop counter addr does not wrap and cause an infinite loop

[ Upstream commit c2f9a4e4a5abfc84c01b738496b3fd2d471e0b18 ]

The loop counter addr is a u16 where as the upper limit of the loop
is an int. In the unlikely event that the il->cfg->eeprom_size is
greater than 64K then we end up with an infinite loop since addr will
wrap around an never reach upper loop limit. Fix this by making addr
an int.

Addresses-Coverity: ("Infinite loop")
Fixes: be663ab67077 ("iwlwifi: split the drivers for agn and legacy devices 3945/4965")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/intel/iwlegacy/common.c