From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C2BB7A00C2 for ; Wed, 28 Sep 2022 07:25:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C15F642B73; Wed, 28 Sep 2022 07:25:44 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60068.outbound.protection.outlook.com [40.107.6.68]) by mails.dpdk.org (Postfix) with ESMTP id 9A61D42836; Wed, 28 Sep 2022 07:25:42 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PTab9pIaMfXB8nH/iPL5JhTRxyfzqtkgs0Rv7K25w2KQN2azzyUUvS1nZWW3bZ92MWsiATp2GNBZl+3VyFuhJwEaL6ySRca1Ah7ufQjMgfDf1WcWy12vjUImqS0tuaUlhcSKam5IBDOBb26U1zkffLtqlauirioqiTLyOwHHkrTHd3qdG00mapDurdMAUxpHHuPzmZZH6DrN8uBaqiRG2HjwgrE6/d8MSFZjQmfUCLX2O0XYXa2p8P7ryH521egLVUxoJKHh4bNlvZlH+EYmNPe06dsCB0D6oXbaTHCobKlN70dlxmoxnYA71Ns+TfFhHX9+ShdguvzLCx9xxdGtvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pDMY9AFvcxLlgm9rxlXk6xs5TvGJ5CK/skV4vabhJTs=; b=n5OS7iZM5SpA8SAOMml9p1w4ivB5c5P1l/FtEBWeJhDwkj8P1eBox4ASeAYBOpQ8k02OJ03Cm8c7f3bvmEsPi9gjj6EPBsRGbtrF0FCGRx56Z4Ys2CM3d8oxeWAN5DpPDlrnIYl5QJtMa5m6H5+V8RDUTjeAB3vV/nLGuWBlZ9pr44ApravVhHbzCkMlXRogGLvOOq5j/wF6bFkdkYDYu9aEYvxwPsablDtVZzrlmDPKTnqLU/iaQCAwP4YxmD1Vgi2dHpU5jv7rYzrL/xqnLYGz9nsnNuA2ohSmX3NGQvy84PSOxkUa4tKvSutzRoTWZalcdU8U2fHU+feVbJa4mA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pDMY9AFvcxLlgm9rxlXk6xs5TvGJ5CK/skV4vabhJTs=; b=Ezm7gREReEnbwmw6y/4aDwEfxrKi/o0rFbEEidzuKw2U6cAMfk7V+fUdLmsmc4TnTtGxVCHQUy77Q9Pt9XaR0Yzer+wImbnOMtaVcbqL772Cw4Mlf/GBY8lN/jzQmycZTTUENsyLooXpfyYGG/xbEtCxfOQyANMjgAeVvEFSEBE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8198.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::14) by PA4PR04MB7504.eurprd04.prod.outlook.com (2603:10a6:102:e6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Wed, 28 Sep 2022 05:25:41 +0000 Received: from AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::14d0:4458:d6ec:b8b1]) by AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::14d0:4458:d6ec:b8b1%7]) with mapi id 15.20.5676.017; Wed, 28 Sep 2022 05:25:41 +0000 From: Gagandeep Singh To: ferruh.yigit@amd.com, dev@dpdk.org Cc: Apeksha Gupta , stable@dpdk.org, Sachin Saxena Subject: [PATCH 03/15] net/enetfec: fix buffer leak issue Date: Wed, 28 Sep 2022 10:55:04 +0530 Message-Id: <20220928052516.1279442-4-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220928052516.1279442-1-g.singh@nxp.com> References: <20220928052516.1279442-1-g.singh@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SGBP274CA0015.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::27) To AS8PR04MB8198.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8198:EE_|PA4PR04MB7504:EE_ X-MS-Office365-Filtering-Correlation-Id: 034bfdd0-06a1-4f7c-41c6-08daa111e296 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Eww1XImaEZRhBv48xPSrCovRjLmGrc0MUxC3mRafWb6XUVz3/oR4owHhRB421u/VTB5nCspY3a/XQo49PAdhtbJaVy7fEB7x7CCUtSMec1txEtwepzZdpWRVR5vmiQ1jdEk9Wqe7KMowVxl22KISsXZGLnejMvw5mUNhqw6yvXdlO+eS9qeKJibn9OwaS/l8mXgIEK6zMBi3t2WlPfYgkYuL23nmqd27O3d+w36hw4Uoh35tN9llguWYRKRcFdtKwwTDt8LyyQYunjrUQ7MfYFZ25kwMFuytLAkY1FNgd526Gb7I7qoka/Pd5hbxp+gts3rtOomuUXJcVxlgdew4BZSMADfIanjEbzqUj4vskc1JXkZOB7s9/bsg8Jsdn6LhqPiu/qn8lrtzSkPxqMg6fZRokut9H+StaiamUhlTONLnbGLpSMO809L3jA68BZbds/xgdkYTJQzshJzQ4e1okA2YQRHA0I8JuRa1QHEnp/m6v8bEZc+e6JYF6EFfOcUEzrmjD15TJq4YkjdN/iZTdke55Gfrk9Yv7Cj78ifuy5NZ8n4Xrdv0aOcJ+XHc2duOro7aOcOsHFs61Wf3QqQ/aJQELmKoD72rWvhYJxIqRMfz+I6r8d/TZU4AHUtNRBnl2zAzLB4oQkViZs2og59Z4G9ObHs83aBbdrsH4t0x0vrXe/aHUslZmvLYZ4WvUOL/YobmPubOLvY7/LGuqEeRS2UGJZ0tD4wC3kRNM/FS9wQwE+Ic5LN/NggmXVovYEPE X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8198.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(346002)(366004)(376002)(396003)(136003)(39860400002)(451199015)(1076003)(186003)(2616005)(8676002)(83380400001)(38350700002)(8936002)(6506007)(38100700002)(26005)(86362001)(6512007)(6666004)(2906002)(5660300002)(52116002)(478600001)(66556008)(66476007)(54906003)(66946007)(316002)(36756003)(41300700001)(4326008)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?FHp9ykR5lJrH8Oa7q9l3+TwSkh87zw941MLUCWEhj2Je0Ki+jK+a7+xMTYoY?= =?us-ascii?Q?7UzF32FtmqQtX2zPcWsczXar2Tis0xPMXqylv6nlodwd7c3nxq9LRRZ4gOer?= =?us-ascii?Q?WcmAJ1kruGV7QO+hoCIg3ghrFjnzFbI9Gv3PlQpgNJ1wfIwIbued8xLb+t5w?= =?us-ascii?Q?XYRjM4ulM2+VWC8AqtHr22dec01WzIz5W0+u57i+A/HeHfYCSR9y/Jx+30Yf?= =?us-ascii?Q?6Dn/8Z7oIoybgsn15IyOAj7ZN694fPLd86JMulYYqfDtJuhca0Z8w+4m/Jx+?= =?us-ascii?Q?YT8uP0Qr6MBBQ2pjjeyGvOOKirj16yLMyge3jhIJHkq4dwBvpOjs4hgbpqSK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dmQ9jzqhLuTJAnN10vsN4YhnwVGsk0j?= =?us-ascii?Q?V/U+4Cswq8ua88H43w8CJTdQkmjr6QFKUEw81ZJWpY4CMbr8fi6mJpa3nx2/?= =?us-ascii?Q?Umw2SZrcQbMBCI+5QsO3+Dn7j9l0NuwI5Qd/ZA8c9n0OpQqINYkxwxyNeISD?= =?us-ascii?Q?b66R3VNK3BISQOaRsupKQS4TjknGFwFAEJDeSMl2b4ED8L53J9jvS0nl0tdw?= =?us-ascii?Q?OtraFYuUTe3xSurfH1MdudEyMvL06GglPsmNCzYyWaDNat9Z4k7mRdPwWpM1?= =?us-ascii?Q?FEv7UPln1hV5XBtPyixPamUB9IRtdksNhpKc0w8XlRG1/043v1uoppLA4r6z?= =?us-ascii?Q?JV9rILxbeXNZ8kJd7/FanS8hhx3ymsoZYoK+fDx8?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 034bfdd0-06a1-4f7c-41c6-08daa111e296 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8198.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 05:25:41.7953 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3Np93FBPqTcaxRfDB3L2OSOQu3V9wbHvbx19fF8cOMzC5Ck//+ziuZ2CwkBvbamx X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7504 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: Apeksha Gupta Driver has no proper handling to free unused allocated mbufs in case of error or when the rx processing complete because of which mempool can be empty after some time. This patch fixes this issue by moving the buffer allocation code to the right place in driver. Fixes: ecae71571b0d ("net/enetfec: support Rx/Tx") Cc: stable@dpdk.org Signed-off-by: Apeksha Gupta Signed-off-by: Sachin Saxena --- drivers/net/enetfec/enet_rxtx.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/net/enetfec/enet_rxtx.c b/drivers/net/enetfec/enet_rxtx.c index 49b326315d..0aea8b240d 100644 --- a/drivers/net/enetfec/enet_rxtx.c +++ b/drivers/net/enetfec/enet_rxtx.c @@ -39,11 +39,6 @@ enetfec_recv_pkts(void *rxq1, struct rte_mbuf **rx_pkts, if (pkt_received >= nb_pkts) break; - new_mbuf = rte_pktmbuf_alloc(pool); - if (unlikely(new_mbuf == NULL)) { - stats->rx_nombuf++; - break; - } /* Check for errors. */ status ^= RX_BD_LAST; if (status & (RX_BD_LG | RX_BD_SH | RX_BD_NO | @@ -72,6 +67,12 @@ enetfec_recv_pkts(void *rxq1, struct rte_mbuf **rx_pkts, goto rx_processing_done; } + new_mbuf = rte_pktmbuf_alloc(pool); + if (unlikely(new_mbuf == NULL)) { + stats->rx_nombuf++; + break; + } + /* Process the incoming frame. */ stats->ipackets++; pkt_len = rte_le_to_cpu_16(rte_read16(&bdp->bd_datlen)); @@ -193,7 +194,16 @@ enetfec_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) tx_st = 0; break; } + + mbuf = *(tx_pkts); + if (mbuf->nb_segs > 1) { + ENETFEC_DP_LOG(DEBUG, "SG not supported"); + return pkt_transmitted; + } + + tx_pkts++; bdp = txq->bd.cur; + /* First clean the ring */ index = enet_get_bd_index(bdp, &txq->bd); status = rte_le_to_cpu_16(rte_read16(&bdp->bd_sc)); @@ -207,9 +217,6 @@ enetfec_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) txq->tx_mbuf[index] = NULL; } - mbuf = *(tx_pkts); - tx_pkts++; - /* Fill in a Tx ring entry */ last_bdp = bdp; status &= ~TX_BD_STATS; @@ -219,10 +226,6 @@ enetfec_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) stats->opackets++; stats->obytes += buflen; - if (mbuf->nb_segs > 1) { - ENETFEC_DP_LOG(DEBUG, "SG not supported"); - return -1; - } status |= (TX_BD_LAST); data = rte_pktmbuf_mtod(mbuf, void *); for (i = 0; i <= buflen; i += RTE_CACHE_LINE_SIZE) @@ -268,5 +271,5 @@ enetfec_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) */ txq->bd.cur = bdp; } - return nb_pkts; + return pkt_transmitted; } -- 2.25.1