serial: mxs-auart: Fix potential infinite loop
authorAnton Vasilyev <vasilyev@ispras.ru>
Tue, 7 Aug 2018 10:59:05 +0000 (13:59 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Nov 2019 17:46:54 +0000 (18:46 +0100)
commit87153f7a04c9904625537d9a552eff56dfd5cef0
treeed8e388ff29867f2c7f9a0a84d7a8bbc05ed2459
parent400caa3d02ea1628b6e14fef44805e64ab6172a8
serial: mxs-auart: Fix potential infinite loop

[ Upstream commit 5963e8a3122471cadfe0eba41c4ceaeaa5c8bb4d ]

On the error path of mxs_auart_request_gpio_irq() is performed
backward iterating with index i of enum type. Underline enum type
may be unsigned char. In this case check (--i >= 0) will be always
true and error handling goes into infinite loop.

The patch changes the check so that it is valid for signed and unsigned
types.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tty/serial/mxs-auart.c