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 BF97E468E4 for ; Thu, 12 Jun 2025 23:09:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B9D7D42E45; Thu, 12 Jun 2025 23:09:13 +0200 (CEST) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mails.dpdk.org (Postfix) with ESMTP id 7AE0F42E45 for ; Thu, 12 Jun 2025 23:09:12 +0200 (CEST) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-450cfb79177so8525525e9.0 for ; Thu, 12 Jun 2025 14:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749762552; x=1750367352; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B8R4ZutA2sue0Golux5GVOIEcggwJyJd6VnGBHN6OfQ=; b=R5VtsV5K1GT6KxHYJ/5RU+l400II5N4yCPUHVXFXssHUw7UBTn0XiBmGh0FGVNkWBT I0b3THTFUkwa+UitBr9I7LLallauWigmL+SVVA6GREH8IAMQ/w2ht71NOiDX58h8bkEF 1eSlinU/rPjIIyEJxr5LeEiFdhBWJPJzlMYfvK+yrMpbbJU+5ic9lgI0G4kgLmOxcvQP lIR+n3JPbsqObJoaR+geg8g/KHwUf6lcul6tua/aKdw8eTmyqPz3ZgWOlzApZ3xQKgNl 2xb+HaCLxs3G+clMQjE6PWJQETfhxSXA8uePlnGQ002r+vkUtjUfXlf0nj+L7uYeNxMX VKvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749762552; x=1750367352; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B8R4ZutA2sue0Golux5GVOIEcggwJyJd6VnGBHN6OfQ=; b=ZG8pQTHOziuCQE2kVdNKlRaFhgCq8rGpBl7XJbRPD8QJJGlQH+xfBE/hQhb/WY7NPs tRZ86DouLTVeV2Ip7dURENmU6SYW2r3J31poSbgoR01wc+oCMMpnWz4n8FBDg665fIex 4qEiL4/PWc9b2eZ0q/BPwSxMUqiazDSKZdBTcOssEwr8KPAcsXYTKDoQyvLK84nMXSI6 92FxQgrCqkruUXrls+11V6sAzS2EJs9Rw4fMh5MY2XBg45gomJuOiL6iqyY6ChZUk6M4 pqL2G06vRY1US8ua3LRtKH8b1mr6yxJBGHid6tR6y6B0YgtBOQDPUqg3f/iFqjsjelm2 b7Mg== X-Gm-Message-State: AOJu0YwP0SnqONuLWQPGBsKMBAzNgiiFboPRPiInUHvueghwSVjdiKOH uQavx+daZgaeRmtO1H/s5ZeZGXo20OOPV/ZHzbtO5OfTWsj2MSW1ydqpSp6m7vrH X-Gm-Gg: ASbGncsWqAPiilOjhVOrctBLv6+JYwlF3k5dX9zDEUlib3ZmZ+e6Dr2Se+n9A3kdkAN QKnNTVH+qyDFLfsCGdLjY0OtC8MFT/P6zGuijwrL7zgiCtZOtBr36UiNbQqEKYa+ES5AVoZpqRh YJs32dO7+kiyszQhHfkozYtc/VQP2qJi1Ex3K6yEtKpAxDquqxjaWZYVZ2hRbHlueWEiPQS6uSY hvS+Ye0JlMJKP+boHVV0dUNy62KS2HYNps1O3ckB9NGe6nsVhioLp1NimsOPwLRO87q/hpboaNm iRVNoL2Wju+5aVgbPI3Udlkbc/JbEWhlVPIX16tat1mKhGToRGBtuC6iCEoo+Akkx8ml X-Google-Smtp-Source: AGHT+IEV90FGkx0P5qkSMHxPbxkpQm4lxIZJz6XGfK+TuIL5IvBEwTLbrc0wcI0npC6bLFOcm0E4yA== X-Received: by 2002:a05:6000:420d:b0:3a4:f663:acb9 with SMTP id ffacd0b85a97d-3a5686e43e3mr503333f8f.9.1749762551976; Thu, 12 Jun 2025 14:09:11 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:f2df:571a:ae4c:bef2]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4532e2522b1sm31159055e9.25.2025.06.12.14.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jun 2025 14:09:11 -0700 (PDT) From: luca.boccassi@gmail.com To: Dengdui Huang Cc: dpdk stable Subject: patch 'net/hns3: fix memory leak on failure' has been queued to stable release 22.11.9 Date: Thu, 12 Jun 2025 22:06:45 +0100 Message-ID: <20250612210733.2506558-28-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250612210733.2506558-1-luca.boccassi@gmail.com> References: <20250612210733.2506558-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Hi, FYI, your patch has been queued to stable release 22.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/14/25. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/48ae218283ce18fec7fdb164ea232ba2d86d337a Thanks. Luca Boccassi --- >From 48ae218283ce18fec7fdb164ea232ba2d86d337a Mon Sep 17 00:00:00 2001 From: Dengdui Huang Date: Tue, 8 Apr 2025 16:30:55 +0800 Subject: [PATCH] net/hns3: fix memory leak on failure [ upstream commit 1c27385dcef1384a1a10edd86bb843b06547b161 ] When the hns3_dfx_reg_fetch_data() function returns from processing failure, cmd_descs is not freed, which leads to leakage. This patch fit it. By the way, this patch uses calloc to apply for heap memory instead of hugepage memory. Fixes: ef1fbd355451 ("net/hns3: add more registers to dump") Signed-off-by: Dengdui Huang --- drivers/net/hns3/hns3_regs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c index e92e43959f..816e191808 100644 --- a/drivers/net/hns3/hns3_regs.c +++ b/drivers/net/hns3/hns3_regs.c @@ -445,7 +445,7 @@ hns3_get_dfx_regs(struct hns3_hw *hw, void **data) for (i = 0; i < opcode_num; i++) max_bd_num = RTE_MAX(bd_num_list[i], max_bd_num); - cmd_descs = rte_zmalloc(NULL, sizeof(*cmd_descs) * max_bd_num, 0); + cmd_descs = calloc(max_bd_num, sizeof(*cmd_descs)); if (cmd_descs == NULL) return -ENOMEM; @@ -459,7 +459,7 @@ hns3_get_dfx_regs(struct hns3_hw *hw, void **data) break; reg_val += hns3_dfx_reg_fetch_data(cmd_descs, bd_num, reg_val); } - rte_free(cmd_descs); + free(cmd_descs); *data = (void *)reg_val; return ret; -- 2.47.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-06-12 22:06:24.933504122 +0100 +++ 0028-net-hns3-fix-memory-leak-on-failure.patch 2025-06-12 22:06:23.846044130 +0100 @@ -1 +1 @@ -From 1c27385dcef1384a1a10edd86bb843b06547b161 Mon Sep 17 00:00:00 2001 +From 48ae218283ce18fec7fdb164ea232ba2d86d337a Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 1c27385dcef1384a1a10edd86bb843b06547b161 ] + @@ -14 +15,0 @@ -Cc: stable@dpdk.org @@ -18,2 +19,2 @@ - drivers/net/hns3/hns3_regs.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) + drivers/net/hns3/hns3_regs.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) @@ -22 +23 @@ -index 8a6ddbfe8c..5c74f9ae2e 100644 +index e92e43959f..816e191808 100644 @@ -25 +26 @@ -@@ -1270,7 +1270,7 @@ hns3_get_dfx_regs(struct hns3_hw *hw, struct rte_dev_reg_info *regs, uint32_t mo +@@ -445,7 +445,7 @@ hns3_get_dfx_regs(struct hns3_hw *hw, void **data) @@ -34,10 +35,3 @@ -@@ -1290,13 +1290,14 @@ hns3_get_dfx_regs(struct hns3_hw *hw, struct rte_dev_reg_info *regs, uint32_t mo - if (regs_num != hns3_reg_lists[i].entry_num) { - hns3_err(hw, "Query register number differ from the list for module %s!", - hns3_get_name_by_module(i)); -+ free(cmd_descs); - return -EINVAL; - } - hns3_fill_dfx_regs_name(hw, regs, hns3_reg_lists[i].reg_list, regs_num); - regs->length += regs_num; - data += regs_num; +@@ -459,7 +459,7 @@ hns3_get_dfx_regs(struct hns3_hw *hw, void **data) + break; + reg_val += hns3_dfx_reg_fetch_data(cmd_descs, bd_num, reg_val); @@ -46,0 +41 @@ + *data = (void *)reg_val; @@ -49 +43,0 @@ - }