8250-men-mcb: fix error checking when get_num_ports returns -ENODEV
authorColin Ian King <colin.king@canonical.com>
Sun, 13 Oct 2019 22:00:16 +0000 (23:00 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 10 Nov 2019 10:27:25 +0000 (11:27 +0100)
commit05dd6283b8fc4d16413b6318dc8a4ed6078e4447
treeed90a0650e3f341079ed2fb04d9a7a14f5eb371b
parent81809424cad7ee577107fd87a6291d4751f3b496
8250-men-mcb: fix error checking when get_num_ports returns -ENODEV

[ Upstream commit f50b6805dbb993152025ec04dea094c40cc93a0c ]

The current checking for failure on the number of ports fails when
-ENODEV is returned from the call to get_num_ports. Fix this by making
num_ports and loop counter i signed rather than unsigned ints. Also
add check for num_ports being less than zero to check for -ve error
returns.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: e2fea54e4592 ("8250-men-mcb: add support for 16z025 and 16z057")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Michael Moese <mmoese@suse.de>
Link: https://lore.kernel.org/r/20191013220016.9369-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tty/serial/8250/8250_men_mcb.c