tty: serial: lpc32xx_hs: fix handling platform_get_irq result
authorAndrzej Hajda <a.hajda@samsung.com>
Mon, 21 Sep 2015 13:33:38 +0000 (15:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 4 Oct 2015 18:09:21 +0000 (19:09 +0100)
The function can return negative values.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/lpc32xx_hs.c

index e92d7ebe9e77e545dae5de45db8857535de123a6..7eb04ae71cc876c2fcd3f4826feb29f6d01b11cc 100644 (file)
@@ -691,12 +691,13 @@ static int serial_hs_lpc32xx_probe(struct platform_device *pdev)
        p->port.mapbase = res->start;
        p->port.membase = NULL;
 
-       p->port.irq = platform_get_irq(pdev, 0);
-       if (p->port.irq < 0) {
+       ret = platform_get_irq(pdev, 0);
+       if (ret < 0) {
                dev_err(&pdev->dev, "Error getting irq for HS UART port %d\n",
                        uarts_registered);
-               return p->port.irq;
+               return ret;
        }
+       p->port.irq = ret;
 
        p->port.iotype = UPIO_MEM32;
        p->port.uartclk = LPC32XX_MAIN_OSC_FREQ;