net: stmmac: Fix error handling path in 'alloc_dma_rx_desc_resources()'
authorChristophe Jaillet <christophe.jaillet@wanadoo.fr>
Sat, 8 Jul 2017 07:46:33 +0000 (09:46 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 11 Jul 2017 20:33:53 +0000 (13:33 -0700)
If the first 'kmalloc_array' within the loop fails, we should free what
as already been allocated, as done in all other error handling path.

Fixes: 54139cf3bb33 ("net: stmmac: adding multiple buffers for rx")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 19bba6281dab703fa3bd96467e645da890abdb0e..4322fa4a13e8efce2df69363f4635c4c5d581771 100644 (file)
@@ -1498,7 +1498,7 @@ static int alloc_dma_rx_desc_resources(struct stmmac_priv *priv)
                                                    sizeof(dma_addr_t),
                                                    GFP_KERNEL);
                if (!rx_q->rx_skbuff_dma)
-                       return -ENOMEM;
+                       goto err_dma;
 
                rx_q->rx_skbuff = kmalloc_array(DMA_RX_SIZE,
                                                sizeof(struct sk_buff *),