From: Christophe Jaillet Date: Sat, 8 Jul 2017 07:46:43 +0000 (+0200) Subject: net: stmmac: Fix error handling path in 'alloc_dma_tx_desc_resources()' X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6941f7cc71a719089f7add4afc82bb80fc5a281d;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git net: stmmac: Fix error handling path in 'alloc_dma_tx_desc_resources()' 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: ce736788e8a9 ("net: stmmac: adding multiple buffers for TX") Signed-off-by: Christophe JAILLET Acked-by: Giuseppe Cavallaro Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 4322fa4a13e8..07d486a70118 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1561,7 +1561,7 @@ static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv) sizeof(*tx_q->tx_skbuff_dma), GFP_KERNEL); if (!tx_q->tx_skbuff_dma) - return -ENOMEM; + goto err_dma_buffers; tx_q->tx_skbuff = kmalloc_array(DMA_TX_SIZE, sizeof(struct sk_buff *),