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 47C3445B1B for ; Sat, 12 Oct 2024 09:27:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 383C8402D9; Sat, 12 Oct 2024 09:27:06 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2066.outbound.protection.outlook.com [40.107.93.66]) by mails.dpdk.org (Postfix) with ESMTP id B456440265; Sat, 12 Oct 2024 09:27:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Xvd1pIq33oTMlGqU68dQuEiWa7gtRaS+jDlLIXIn+EHjzVONNVE14v3krnhxgsQ4jdP5EJtULLSbSmT2xGfBLDBoyNClHhg0uXyCvMGAu2WSfFaTIxlc3DoX3ICo6W/IhGlx80nF2ucwnLEXdptAP+qQdRBDlTati5MNLjCsL8yfEY02IpkNrh+QGMbyMWujr6ZFXpGuMvKpPz12bU65xGT46W322Qk6diVHAg9siozkcbR/A113Wpm+734YImofA5NjZo6sZZwFoR+E7ieCRIlDhV722tUbm5JzaMtb0/NgG+TJjMMnIDZNkoqMTI7M204qXby6GotvBN1m5B9mRQ== 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=6HfvS5A+UjjgZZRr6zFJvEJdkrgfP+oTY/iyoYf+Ggo=; b=f6llChhqrsWbiERuV7DqwyMYNvYOKBHlzwin9PLAAzGn9dcmWbARKeZY9uCi7/I0n2uoCHRwbpqdX8WXLpBYzqAe2cU3eoRFGMQI932m7HNS6r2dtuhOCC1iBIk0xZu06arglwhgsJ+gPJhR4/I68Jmc5pvYgWn4LLXMDf76a+vqg8fbLaONpZrJkt+dbFtrqmzNmuq0pgAOTHwKpgJN+T0sldnyGsIojwon7H5bc84x+GfYneT4bqtf5QN57Og4bKruN6okCdeOUo/QktEAdayCH9IJXnBx+/YoNVfklTdibvb05dQ/0dCUH8Hm8+EzCh3do5S/JYMoNtoBvJWMiQ== 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=6HfvS5A+UjjgZZRr6zFJvEJdkrgfP+oTY/iyoYf+Ggo=; b=nqL9/fQi2wjWnYlyNpo4FwKBc3GRIc8wyx5njckXLJ7Kcq2nBTVTs1t9EaH+wj9Ivh9NoRWETOV5hGIwsF6gAy+w7Y2RJ4/QGt2J+oJ6jBl9hRuHO7jbK/Eu8/Y5+4XpRoV9x0JDF3GMHTZzyGioHofrQFcaiXhmQo/8pN9XqDFYtryslcYpJ+Us02GZCDqUcZ/0/OJ/VqFSkdKfoCR52EO+Q4XZi7jMBH8DUN2dFuKpBOeXhtsT0Ur+UC65V95PIM4gCPT9KHR+0p0di7HMtnkEBFKrW0EDS/Qr/1P/yhsGW0yogAddjQ9UboKmIzFSbWtraZ6i86WrSojhHoZokg== Received: from DS7PR06CA0037.namprd06.prod.outlook.com (2603:10b6:8:54::12) by DM4PR12MB6159.namprd12.prod.outlook.com (2603:10b6:8:a8::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.21; Sat, 12 Oct 2024 07:26:58 +0000 Received: from DS3PEPF000099E2.namprd04.prod.outlook.com (2603:10b6:8:54:cafe::58) by DS7PR06CA0037.outlook.office365.com (2603:10b6:8:54::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.22 via Frontend Transport; Sat, 12 Oct 2024 07:26:58 +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 DS3PEPF000099E2.mail.protection.outlook.com (10.167.17.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Sat, 12 Oct 2024 07:26:58 +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; Sat, 12 Oct 2024 00:26:57 -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; Sat, 12 Oct 2024 00:26:54 -0700 From: Shun Hao To: , , , "Dariusz Sosnowski" , Bing Zhao , Suanming Mou CC: , , Subject: [PATCH] net/mlx5: fix potential memory leak in meter Date: Sat, 12 Oct 2024 10:26:40 +0300 Message-ID: <20241012072641.3396372-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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099E2:EE_|DM4PR12MB6159:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f529e34-26f2-4fb1-ea02-08dcea8f4194 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?kwSwS3QFXvsVu0ptgHroxWyUVfXStDQ6h9onejIcrVtxBJ/mGJsaa3QRAxyA?= =?us-ascii?Q?lj80BhVA3OO9O5z1aLGEfdZu3LkDTzILiF2cvi40IJ7KfcqooXjn1aAaEIuJ?= =?us-ascii?Q?6RJeeV+ZLRzQPWd72mR6XEAfx72jhAjVbd/OC4rVsw9eAHkrUVJukYr3wbYV?= =?us-ascii?Q?txObk5B8+TglCRl/o+WYS1VoSyMkVGGvqgwmFPRLp5B1r1JwiS+6ugafa6cA?= =?us-ascii?Q?IiUDs6FExQSYHO7QnGn5+jOGUwtD90hoGal43+w1abVFGVvzyaBjqmJ+R3Zg?= =?us-ascii?Q?Aa9hoafcAuPSLEE/iHaiM8C8amoQHHGnoN3q0SsHDZQBKiSxzqhmC66jBW6b?= =?us-ascii?Q?PzvXk2hMLE4eJHvi7Zbw90tggHVCG+KYQUbXEiI35yVwbZC9kyFWqdKSG8FX?= =?us-ascii?Q?9zFTaolgVpqb9Ps78PjQrgacRKNwNVz2WS7vhLdnLvHBBlIHVeHc0mLdT6+Y?= =?us-ascii?Q?ZN9DLdKsWc30ehuoNGgvp+fATBqxyp5VZ1jxVvGm65/SsZV4Z0Al1djfmjJv?= =?us-ascii?Q?jZgULsvsXaSxza7evkB4SxdGGC8oqLPoX0spp3S7V1YgEW83VqRZDXci7JpN?= =?us-ascii?Q?VG62+6mFWYat+2qg+fvQC9mdHD2qPg9/+YwG12bI7UAr5S/3V2ySr+maxnCm?= =?us-ascii?Q?PB3zvyFedbT+VIZ/mhqAsUXyV3zQuLzFwqSNp1lFeABQs+y3wK0QOztCBRHH?= =?us-ascii?Q?AC4nPoAie/9/TGzb6PyUlUIQDRSkYvNeWGUYhiQTwPiJsyaEw8gO+Kjac/OQ?= =?us-ascii?Q?HskdP/L/SM0R+4rwZk2uKElbrQtUfoCyOwyyIJlzkmwPOdlpoVNSFetDXTds?= =?us-ascii?Q?qrkyRr48D9b/00sxzoKwSl4QATxhy3tfmItHjpPFnOLsN0nqV36hxXQHL8rC?= =?us-ascii?Q?1OesJ4T5ZbHJyJEEmRV1mkyYkD1DpBpx2Hz3lb/MdNS47fpmGMUxw1NMoZYg?= =?us-ascii?Q?5IiAfPxPjTkpNKTZvYxGSP4r67IHYdCnX1Yrmsnd2YsHNBvGGx+Gknk+mfy+?= =?us-ascii?Q?hTXweoAMW89OMpzq8f+2CLRNT+h2+TGYGMEgBd6egr2+3DCVX0aJu7M3qisV?= =?us-ascii?Q?AnRLKUbUSdBtO8kVrTosRUzoKukXAx8nFWmjImfnScaj7anvhyfc8EX7XJ3W?= =?us-ascii?Q?FBcJykJf+36a5WDsNOUPTMnpKqCQ3MjKF13A+pYQuiVIMOLXiKAhzBv8hcyV?= =?us-ascii?Q?3NvSxaw9hNMAi9XOEIJC+eF1qZBvle/RntiP9sf93hH9EooPip1ocsFUSprp?= =?us-ascii?Q?fFVIvxJ3ZQ1caJDMjgjWCUiJ1aM/iJON+wW8V2XzRxMBdryFErE2u2awnaU4?= =?us-ascii?Q?WMhri6fuzO4nPtF34YajI4OCnxociCeacFNR0wZATxdfflC2sZWCJGL0VKqI?= =?us-ascii?Q?Ag7PufOiwEUpEjvIFHLsNAj1VmEh?= 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: 12 Oct 2024 07:26:58.0175 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f529e34-26f2-4fb1-ea02-08dcea8f4194 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: DS3PEPF000099E2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6159 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 | 3 +-- drivers/net/mlx5/windows/mlx5_os.c | 8 +++++--- 3 files changed, 11 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..50587d6cfb 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -378,8 +378,7 @@ 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