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 1A26745B3C for ; Tue, 15 Oct 2024 03:48:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 142EE402DE; Tue, 15 Oct 2024 03:48:19 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2081.outbound.protection.outlook.com [40.107.223.81]) by mails.dpdk.org (Postfix) with ESMTP id 92A1B4026C; Tue, 15 Oct 2024 03:48:16 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Pgx6VuuJgMFJ7efCdyUrbY5xV4UppOlJfY//RPreAss8L1ye8fqW1uXa6kCwSxF6qd7lbcpAE0nWgzRP7dGkosIxhC6RZelaZLrFlFRyQpCSJRAXoCudFQFOIRIM/9Z4cq8kFbiB8NGJUVXKwodJq/dWBnCt8xSwuX+vntNye77qKNIzLx6QQZkPBPVB5BsroLqH2BYWmL+pFGf1sKyrpVSn9pQLtNzjxFQj7uXst1uySuJRq2meO12AIsN8p/7qNB/c3hpu7j5BGxQ9zAqpLSTkHdRq7efLG5ywVMBbTuPeV9dNZpCp91iFcn4JurKAecXxYRobtJexTuCEusRpiw== 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=YRxKjWeSgdhWBzYf62Gv3Y4gsJ4LMf97GR7AM10ytJSdZ6ZMoHfeuNx17Fq9N3y4qhurzXVG7BllbmP7v/mcY1J3DD0/6uoP0xRqVkAlX+OD36QwHOLLmah75uWjxKc2mPI21l1esDlEEBkOyCUDOtsFISyansvbpW6P1GTQ3SvAO6vvV0ldNfhJi+X2NO2nN5e4Bxn68ncukgHlu0qcYo2BXvggGWvADqpeUVh6tnv2V7XTM06YHT6UcWOrujc5hB3i2SAVHUHRBPAI89NR0pREFhDGeY7qiUPFOCkktajXH5bEOYjlj0p07x5i5c9azxg0I+k0hOT9q7JIOp0oIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=tTGuNccxVlKiUdAL7gZcF3gmJii/AVRuP6Tg7CUKJEZ1Trkcr8DDZaFZBfDIDz+3QJT+vhez8rwkgAahLNFPqZyYAePqoqYXmwTvQgGTdyIq5vKvrdj6SYSI6phq/5PSoX2tPi2h7q+9InNWhXZrPAtthRE+CbTcfU6UcyJMAL9TvAvM4RDoyGI8QMe/F0+0cmiSgMwauOeP492pOOT04N+zTG9IBCX6aCNBWsnRRazqH/ig6SJflgCGrXGvnXAU2fsTpnUVKOYYE5DtdOsbed8z0XeZD/mchaBDGob6MTuqnA2aUhykzrFgUOzEWy2TeIL3JKsp34I9Pzw95NyoOg== Received: from DM6PR02CA0160.namprd02.prod.outlook.com (2603:10b6:5:332::27) by DS0PR12MB7654.namprd12.prod.outlook.com (2603:10b6:8:11d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 01:48:07 +0000 Received: from DS3PEPF000099DD.namprd04.prod.outlook.com (2603:10b6:5:332:cafe::d0) by DM6PR02CA0160.outlook.office365.com (2603:10b6:5:332::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 01:48:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DS3PEPF000099DD.mail.protection.outlook.com (10.167.17.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 01:48:07 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 14 Oct 2024 18:47:54 -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; Mon, 14 Oct 2024 18:47:51 -0700 From: Shun Hao To: , , , "Dariusz Sosnowski" , Bing Zhao , Suanming Mou CC: , , Subject: [PATCH v2] net/mlx5: fix potential memory leak in meter Date: Tue, 15 Oct 2024 04:47:36 +0300 Message-ID: <20241015014737.3805449-1-shunh@nvidia.com> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20241012072641.3396372-1-shunh@nvidia.com> References: <20241012072641.3396372-1-shunh@nvidia.com> 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: DS3PEPF000099DD:EE_|DS0PR12MB7654:EE_ X-MS-Office365-Filtering-Correlation-Id: 30eb316e-833b-46bc-c77d-08dcecbb6aae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?TkSni7izrxtyDUyYfVG6RhK77wq2BGoRestF7Ds8EzpZ6Oad/tW+YwQMNmU/?= =?us-ascii?Q?0DfGrywErMMr2siT2ZDP8oc1UbfXS1nBsZkC/AOy2P207gDmFUPt6uWYWjA8?= =?us-ascii?Q?zpAKnONZ8vanpIEVuxs7EL7ApiO9bDhpjCQiYIk/wnNuP4SRMmkD0iR9rqj2?= =?us-ascii?Q?zDEGbnn2SR+7IES48/DjXiIYLYOlDsbH7tLWbIKDUPR/C8m26TWS2RImxuFN?= =?us-ascii?Q?3WEyKE9831LWhfa965Zw6l7P4CVCzf4xDXd0e3LFAenI2GTh6waCSacTMDiF?= =?us-ascii?Q?goIof+UmEDnucDvkf+W88tRmF5iTzJy1IkUoq3d79xwkUw0NaHEy2Anw2l6J?= =?us-ascii?Q?hdVnCPBHX0HaulKCQ1PYXw0mlDWLisuAoirmpnJNkCrkBZN2m1VPwmN+xtjy?= =?us-ascii?Q?TvDU8iBiAetTls/osXh8uGx99ZzcWeTFCRBXMYfhSD65MsrzDFSBoxSc7pFy?= =?us-ascii?Q?zDOJ/RUDha4k8MSEXqiOU9iAnE1Y70qIp8UoXATS58fS+BvdajdSBZOmTjQQ?= =?us-ascii?Q?mpSjxEtHbsIhyhYuOmNlf7XT8L114w7KWzqYwFWhNyIImT4d6yV4cv92ZE8O?= =?us-ascii?Q?6rco3+kB9JYW7c10YVhQcSLr0ppMuNvvYlv+rk05wsfWenBSRd3t9TN79svu?= =?us-ascii?Q?ZQFbGuLyoj4QkiDeup8MbyBErZu2676hdhtu69pCot7Rp42F2/TD2BLpCesf?= =?us-ascii?Q?QRMeLcHgGTrH00z9TABBsiIP48iJP2xOG3V0WRERM5+amDMK3LYafwoy46oc?= =?us-ascii?Q?dFGVrHQv/Qg3eC36uKnohOrcjxfADvLNlLPS0OngtH9X0b59kPVf73xOqADm?= =?us-ascii?Q?sXWlgVQPHdOMryRitd5LVl9xhIvWp9lAKQ2a9jbvb/+fxFj214ExksGywVRu?= =?us-ascii?Q?olkIixaH0xHc8zY6AV/5ID2VDz9dMQMvkY06DDaRpd322DA9N+cDW0OIwx1/?= =?us-ascii?Q?gUvoAcXp8U0SFDnlTBJd8nuttuN3JE+ezwiaMam1d9cMA4t6sGbx7nbCHRUI?= =?us-ascii?Q?T9vs6ibNx2jLWhi5OvDuQHO7omGVMDL7xZtssQxH0mUXKOgz1fnUkE87B2Bn?= =?us-ascii?Q?x/T/mfnYzi5Q257hlhtJYeHb08IUf8ZYAA6+fY3hJ+aMIOgj4hGiAWuFWAEg?= =?us-ascii?Q?nSEDuN/GSCTov+grQfbmGmez8ZkQJZRU9Ygh3nzGcjRT59N5vrKFN6/NDTxr?= =?us-ascii?Q?7snoqSFdbucCutk/JogYg+Tip2Zs7Y3Y7slhNyCehiYsLvyshyPdV642uQej?= =?us-ascii?Q?7CxeU5si8bhBMy+Hbzdqdyc5Ns5BKz2gW0KSGwndebEdXfjGBFxXAe5UL0E8?= =?us-ascii?Q?EdV1v6xeigQRa7fUHZ5fW2SQJk3/kawuHPypWGr8eD0/7nhj3x8ybt+FNMtA?= =?us-ascii?Q?Zr6NSYEbZ37b0SZIUgl0LmDlJ5Ri?= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 01:48:07.1084 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 30eb316e-833b-46bc-c77d-08dcecbb6aae 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DD.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7654 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