net: sxgbe: fix error paths in sxgbe_platform_probe()
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Sat, 26 Mar 2016 21:24:09 +0000 (22:24 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Mar 2016 02:39:22 +0000 (22:39 -0400)
We need to use post-decrement to ensure that irq_dispose_mapping is
also called on priv->rxq[0]->irq_no; moreover, if one of the above for
loops failed already at i==0 (so we reach one of these labels with
that value of i), we'll enter an essentially infinite loop of
out-of-bounds accesses.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Francois Romieu <romieu@fr.zoreil.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c

index b02eed12bfc5743117285216db1b4fe6ba19536e..73427e29df2afb808a0b525ebb1978df4d76a996 100644 (file)
@@ -155,11 +155,11 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
        return 0;
 
 err_rx_irq_unmap:
-       while (--i)
+       while (i--)
                irq_dispose_mapping(priv->rxq[i]->irq_no);
        i = SXGBE_TX_QUEUES;
 err_tx_irq_unmap:
-       while (--i)
+       while (i--)
                irq_dispose_mapping(priv->txq[i]->irq_no);
        irq_dispose_mapping(priv->irq);
 err_drv_remove: