From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752461AbdGJGV5 (ORCPT ); Mon, 10 Jul 2017 02:21:57 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:52520 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751161AbdGJGVz (ORCPT ); Mon, 10 Jul 2017 02:21:55 -0400 Subject: Re: [PATCH 1/3] net: stmmac: Fix error handling path in 'alloc_dma_rx_desc_resources()' To: Christophe JAILLET , References: <12c5a0a87b6ef1ae40e35e247703082a671f2934.1499499451.git.christophe.jaillet@wanadoo.fr> CC: , , From: Giuseppe CAVALLARO Message-ID: Date: Mon, 10 Jul 2017 08:21:50 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <12c5a0a87b6ef1ae40e35e247703082a671f2934.1499499451.git.christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG2NODE1.st.com (10.75.127.4) To SFHDAG4NODE1.st.com (10.75.127.10) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-10_03:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/8/2017 9:46 AM, Christophe JAILLET wrote: > 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 Acked-by: Giuseppe Cavallaro > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index 19bba6281dab..4322fa4a13e8 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -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 *),