]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
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>
Tue, 18 Sep 2018 14:07:24 +0000 (16:07 +0200)
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>
drivers/tty/serial/mxs-auart.c

index 76aa289652f7ae20a532e9355affc501de8fe763..27235a526cce8c4b59aa14f6764e466b10988748 100644 (file)
@@ -1634,8 +1634,9 @@ static int mxs_auart_request_gpio_irq(struct mxs_auart_port *s)
 
        /*
         * If something went wrong, rollback.
+        * Be careful: i may be unsigned.
         */
-       while (err && (--i >= 0))
+       while (err && (i-- > 0))
                if (irq[i] >= 0)
                        free_irq(irq[i], s);