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 5C22D45BAC for ; Wed, 23 Oct 2024 08:22:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5592140B8F; Wed, 23 Oct 2024 08:22:51 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2056.outbound.protection.outlook.com [40.107.243.56]) by mails.dpdk.org (Postfix) with ESMTP id 1842C40B8F; Wed, 23 Oct 2024 08:22:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=s2mNa2hcqB6s4tE2HDj8qdKBUuKd1nWLIiiphPERnEG3nyBkmIogrdxc0mQ5SuGl3c5UfUUe6VLEfc0xGG+GqSIq6L/jHf6+qs/pKZxRFJYz9Ni+XX2l3aO3ZIqck+AGSMDIsy5I3byN9B+noUslbXx09w4UJsfa4xrmqLetrONbnviNTpR95fy9F4OMSgDNOG+K4YMHePhr6d4klIVEfAj1R6wT2HqxGsHJF0SfPxLofP29uqCIHbhkrtYICpYyFhjg9lAqgv0HcsiL6CkJehu8Z7vIbf8sQBS4ncLItNEKz+b+W2Uy62fGzRbxmOYeKDYCTQ835QqQXVeZfL5A/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=imMK/j71OO+XIUEUU6+xb5tYhLoQQeF1PS4//qDChCU=; b=tcVx1gKAfh6L8iahgrhex6sA45TUV/xN6H4ZPqiEOQhf7Va0OUT8VDLGO9KYR7HJlbVWjxqsjBALlz6magkLkWmNnuoUr/xaDGFeigb0P0E8/jpNR1Oib6YNPA27LTjpZ5OhJ444/EBEISGYoxXHSkIlGCuFnRrk2mn34Cp4Gn8S16Hw7u9e22njAcukdo9CiJ4sbEBl9DI8dcT3gzv3+mC4mu0PuFpInCGbGpl0VUAc/x7W5z+51aDRhwU2D1PYb1aJpWjt/ChTuWyFxLEg5iILAQ0FEo1TUN2U2iOqseQz6ByHtiRCOvs3Ge5ox99kDXXYjSSbMJgrVn5eGUJ7Yg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=imMK/j71OO+XIUEUU6+xb5tYhLoQQeF1PS4//qDChCU=; b=Iv6IZFyxwI1aXZrxPz491jTf4j3IeF6cAhDvLCIgICHtTx8POIscHGb8SFN6n52qV+DRvZ77gW1WnQYLQ64o1KH+0DAiG9nZ9QZSX06MOhiLh5eg6TboyX/iESdKiImhR2ws28MQIH1Gdt1sJ3a84bsFvC0JnEhHFXaOoQe79H4ENev/daIiVcWqijVRLrYEz4gBVarZn/rd79xsMlhTGVnKwAuMJ5PX+PFosQzR1n0Zr9fEVuqfLDsZBhAPKM2jnMIXrI0j7D75PHY24IktviKrLJmwWzKxVSlccq9mcpi9S8MjaX2hfus1waQ4CcLqWwSkLLwZ535HGPWYnap9xg== Received: from BYAPR11CA0054.namprd11.prod.outlook.com (2603:10b6:a03:80::31) by CH3PR12MB9079.namprd12.prod.outlook.com (2603:10b6:610:1a1::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Wed, 23 Oct 2024 06:22:46 +0000 Received: from SJ5PEPF000001EA.namprd05.prod.outlook.com (2603:10b6:a03:80:cafe::21) by BYAPR11CA0054.outlook.office365.com (2603:10b6:a03:80::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Wed, 23 Oct 2024 06:22:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ5PEPF000001EA.mail.protection.outlook.com (10.167.242.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Wed, 23 Oct 2024 06:22:45 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 23:22:31 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 23:22:29 -0700 From: Shun Hao To: , , , "Dariusz Sosnowski" , Bing Zhao , Suanming Mou CC: , , Subject: [PATCH v3] net/mlx5: fix potential memory leak in meter Date: Wed, 23 Oct 2024 09:22:15 +0300 Message-ID: <20241023062216.967742-1-shunh@nvidia.com> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001EA:EE_|CH3PR12MB9079:EE_ X-MS-Office365-Filtering-Correlation-Id: 4fc562e2-a9ea-47ef-70b6-08dcf32b1bd3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?g1OzbKHJuAWhetFrRKXdmq3T/n26SQHZQk88lzIr58Uw/icf7ulluyk8bWxg?= =?us-ascii?Q?vEosyo/i4D1ota3sKK2CzkV2ozhOtD0YdtaLfb+hpZMra/eyTsb1/GaHJ/r5?= =?us-ascii?Q?cNdTStBwdrXvMzGAHR35vYhRZZ6oKjKim1iFL9wzxdnb483HFc6LQEdCf8Y2?= =?us-ascii?Q?+ij+RPkWFsvzbQB4VYoYVBhSWO7UoBfQGtCTVaBsJNpj8BkMWUPxeSNdUrpp?= =?us-ascii?Q?ga+vzTBLkrsBqMdLikbSwSEXYMe6KAfGd7T8UwyAuOISdf1Hxo/IcFcLAYyJ?= =?us-ascii?Q?Qc/SsHQDREcsOOmkcvzn7h7Ji7RAE3w1lF747PapPHSf0WaJqe8NR2Oy63X/?= =?us-ascii?Q?c9UuuN8K13APxTJTh1VhdrHPttpS3vNwt+2x70TTuCQ/+4Xtnb6GS1NAlWRQ?= =?us-ascii?Q?2Sdh4CK2HtVv3QjUxJk8mpOP5bBlO5IfK5XW/BYpEvefbPP6+SJ9MnR8EX1N?= =?us-ascii?Q?vO6nFxCOplhutUGR4+yXmidwHF8lW5OZNtYN290BxKaRhftD+SihcNiTTXAe?= =?us-ascii?Q?tfwa/RcXr4FHXidGcrzoOgqvekt6nuZQifX19DEFAM8wZ+E8vE5e+a4GQLtx?= =?us-ascii?Q?FGI29qMTo22gXNO4jsazFghEnd/27BE3K2uTwQm1uvmc1T9bWGKif2vuuFm0?= =?us-ascii?Q?2brErURBUlzFFf5KAXvqyomfHd42LrPm/JUBOKDYWSHo2Vsk9oBXMT8CMPTK?= =?us-ascii?Q?W/xz1fUmcwsyRw3MzsssbKR9lkcRhmpUdoeDiqLHgqbCB9APMEvNCZHyutN0?= =?us-ascii?Q?Th0qa3WA39oBDH2Cyjvewbub17U95lPc+UuQySyJjTiZBGWVE+dZjs/BTaQH?= =?us-ascii?Q?Q5wWmfYr/qQAFOGJpQisgfJueV0z0SNRO3YIQXj8L0SJJClLUkGQJ9BJr896?= =?us-ascii?Q?suqSMonnjP+LX7j7BIjElZCEEmZJh1JHBISfc8IzOganmkGfglwg4B2DmRPn?= =?us-ascii?Q?FYPEfMcXrH11lAY7YW31t6kyfp9XhSb4o52FaZit22ebyoX4n9LLHOgc3Zl5?= =?us-ascii?Q?MsrwXiBMPoIj8WxAwPZmwhR3fLDLVKJOAMnEHCnEHt71DLbci4RvWUGbDP6P?= =?us-ascii?Q?rof/32/4vZ90+XU0RyUkK6Tfbc/YtHatFbGROhSQH5vKbkBNvwZM76R2o/RV?= =?us-ascii?Q?9+wk2VGjKRsWJAfysq0FXu8HbFj/g9x5QnvOOqFfU7Vf+YtIBXpfZxEeAtnu?= =?us-ascii?Q?YYudq48AOtd8G2nSoB2FyN3AWIG6A2Shv7pDuMcz+IOniH819w45TMBMELCj?= =?us-ascii?Q?V9/YYqPpHUnksHa1c6sKvbxXwZJLRzo7fpgsqP2JHAJnEqW9m+ZWtwuspK4Z?= =?us-ascii?Q?Xt8FcjtSih8GVU0hsh5YYa/t6nO8g/T/F3A7tg1eJU0bUb5uCSqZ+RrSlQAo?= =?us-ascii?Q?/Slz39O0hRSHPL64V/TyqKeUQWpFgojNxGVeDzFWY1Di4jbozQ=3D=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(82310400026)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 06:22:45.4502 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4fc562e2-a9ea-47ef-70b6-08dcf32b1bd3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001EA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9079 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 When meter not enabled, avoid allocate memory for meter profile table, which will not be freed in close process when meter not enabled Fixes: a295c69a8b24 ("net/mlx5: optimize meter profile lookup") Cc: stable@dpdk.org Signed-off-by: Shun Hao Acked-by: Bing Zhao --- drivers/net/mlx5/linux/mlx5_os.c | 8 +++++--- drivers/net/mlx5/mlx5_flow_meter.c | 4 ++-- drivers/net/mlx5/windows/mlx5_os.c | 8 +++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 0a8de88759..3881daf5cc 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1612,9 +1612,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->ctrl_flows = 0; rte_spinlock_init(&priv->flow_list_lock); TAILQ_INIT(&priv->flow_meters); - priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR); - if (!priv->mtr_profile_tbl) - goto error; + if (priv->mtr_en) { + priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR); + if (!priv->mtr_profile_tbl) + goto error; + } /* Bring Ethernet device up. */ DRV_LOG(DEBUG, "port %u forcing Ethernet interface up", eth_dev->data->port_id); diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index 19d8607070..98a61cbdd4 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -378,8 +378,8 @@ mlx5_flow_meter_profile_find(struct mlx5_priv *priv, uint32_t meter_profile_id) if (priv->mtr_profile_arr) return &priv->mtr_profile_arr[meter_profile_id]; - if (mlx5_l3t_get_entry(priv->mtr_profile_tbl, - meter_profile_id, &data) || !data.ptr) + if (!priv->mtr_profile_tbl || + mlx5_l3t_get_entry(priv->mtr_profile_tbl, meter_profile_id, &data) || !data.ptr) return NULL; fmp = data.ptr; /* Remove reference taken by the mlx5_l3t_get_entry. */ diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index 0ebd233595..61ad06a373 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -521,9 +521,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, claim_zero(mlx5_mac_addr_add(eth_dev, &mac, 0, 0)); priv->ctrl_flows = 0; TAILQ_INIT(&priv->flow_meters); - priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR); - if (!priv->mtr_profile_tbl) - goto error; + if (priv->mtr_en) { + priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR); + if (!priv->mtr_profile_tbl) + goto error; + } /* Bring Ethernet device up. */ DRV_LOG(DEBUG, "port %u forcing Ethernet interface up.", eth_dev->data->port_id); -- 2.20.0