From patchwork Mon Feb 8 14:03:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 378990 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F344FC433DB for ; Mon, 8 Feb 2021 14:10:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B371F64E60 for ; Mon, 8 Feb 2021 14:10:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231945AbhBHOKB (ORCPT ); Mon, 8 Feb 2021 09:10:01 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57214 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232691AbhBHOE2 (ORCPT ); Mon, 8 Feb 2021 09:04:28 -0500 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Joao Pinto , Jose Abreu , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , Russell King , Andrew Lunn , Heiner Kallweit , , , , Subject: [PATCH 02/20] net: stmmac: Free Rx descs on Tx allocation failure Date: Mon, 8 Feb 2021 17:03:23 +0300 Message-ID: <20210208140341.9271-3-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208140341.9271-1-Sergey.Semin@baikalelectronics.ru> References: <20210208140341.9271-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Indeed in accordance with the alloc_dma_desc_resources() method logic the Rx descriptors will be left allocated if Tx descriptors allocation fails. Fix it by calling the free_dma_rx_desc_resources() in case if the alloc_dma_tx_desc_resources() method returns non-zero value. While at it refactor the method a bit. Just move the Rx descriptors allocation method invocation out of the local variables declaration block and discard a pointless comment from there. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 03acf14d76de..5ee840525824 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1791,13 +1791,15 @@ static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv) */ static int alloc_dma_desc_resources(struct stmmac_priv *priv) { - /* RX Allocation */ - int ret = alloc_dma_rx_desc_resources(priv); + int ret; + ret = alloc_dma_rx_desc_resources(priv); if (ret) return ret; ret = alloc_dma_tx_desc_resources(priv); + if (ret) + free_dma_rx_desc_resources(priv); return ret; }