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 1298046BAE for ; Fri, 18 Jul 2025 21:34:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C81A40611; Fri, 18 Jul 2025 21:34:36 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 35B5640E2E for ; Fri, 18 Jul 2025 21:34:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752867273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Owgqa/WCRWgJTROlAdsDLMVIKvdDx5aFxJGyPPda30c=; b=jBkAz1cLa4RjU4T96J0lHfvFALimHanjPYR20BvCYEWIz7ca0OoicYuSFraxx3TEi5zfnQ 2en1lxwzZcOYSYSlsup1mRHVjTnPg8LVnx1jTptTzYfWFg0ic5LNjJl3cmxltUdoUx6GJG 9VYeWxlTbOPWWKDY0nDC8sI0ydJnPZU= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-413-gW2VgnZrPo2KB6RQqOj3fQ-1; Fri, 18 Jul 2025 15:34:30 -0400 X-MC-Unique: gW2VgnZrPo2KB6RQqOj3fQ-1 X-Mimecast-MFC-AGG-ID: gW2VgnZrPo2KB6RQqOj3fQ_1752867269 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8DDDB1800284; Fri, 18 Jul 2025 19:34:29 +0000 (UTC) Received: from rh.redhat.com (unknown [10.44.32.40]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5124918003FC; Fri, 18 Jul 2025 19:34:28 +0000 (UTC) From: Kevin Traynor To: Dengdui Huang Cc: dpdk stable Subject: patch 'net/hns3: fix memory leak for indirect flow action' has been queued to stable release 24.11.3 Date: Fri, 18 Jul 2025 20:29:38 +0100 Message-ID: <20250718193247.1008129-44-ktraynor@redhat.com> In-Reply-To: <20250718193247.1008129-1-ktraynor@redhat.com> References: <20250718193247.1008129-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: yWt4y-rwZB07bO-hzSB_T2HyJ_pxhqXn52qKUM_SftM_1752867269 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 24.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/23/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/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/d3a09d4fef164931865774a0b3eb4ecd527156d3 Thanks. Kevin --- >From d3a09d4fef164931865774a0b3eb4ecd527156d3 Mon Sep 17 00:00:00 2001 From: Dengdui Huang Date: Tue, 8 Apr 2025 16:30:57 +0800 Subject: [PATCH] net/hns3: fix memory leak for indirect flow action [ upstream commit 18596f7be8f93e159e98704af12b1cc8af289dd6 ] Currently, when the application creates an indirect action, the hns3 driver allocates a memory for the structure rte_flow_action_handle and returns this structure pointer to application. When the application invokes the destroy function to destroy the indirect action, the driver releases the memory. However, when the application destroys all flows by using the flush function before destroying the indirect action, the memory is not released. This patch fix it by using uint64_t instead of rte_flow_action_handle* to store indirect action avoids memory leakage. Fixes: fdfcb94d8fb3 ("net/hns3: support indirect counter flow action") Signed-off-by: Dengdui Huang --- drivers/net/hns3/hns3_flow.c | 41 ++++++++++++++++-------------------- drivers/net/hns3/hns3_flow.h | 9 ++++++-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index 266934b45b..c0238d2bfa 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -474,17 +474,18 @@ hns3_handle_action_indirect(struct rte_eth_dev *dev, struct rte_flow_error *error) { - const struct rte_flow_action_handle *indir = action->conf; + struct rte_flow_action_handle indir; - if (indir->indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) + indir.val64 = (uint64_t)action->conf; + if (indir.indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF, action, "Invalid indirect type"); - if (hns3_counter_lookup(dev, indir->counter_id) == NULL) + if (hns3_counter_lookup(dev, indir.counter_id) == NULL) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF, action, "Counter id not exist"); - rule->act_cnt.id = indir->counter_id; + rule->act_cnt.id = indir.counter_id; rule->flags |= (HNS3_RULE_FLAG_COUNTER | HNS3_RULE_FLAG_COUNTER_INDIR); @@ -2727,5 +2728,5 @@ hns3_flow_action_create(struct rte_eth_dev *dev, struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); const struct rte_flow_action_count *act_count; - struct rte_flow_action_handle *handle = NULL; + struct rte_flow_action_handle handle; struct hns3_flow_counter *counter; @@ -2733,12 +2734,4 @@ hns3_flow_action_create(struct rte_eth_dev *dev, return NULL; - handle = rte_zmalloc("hns3 action handle", - sizeof(struct rte_flow_action_handle), 0); - if (handle == NULL) { - rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, - NULL, "Failed to allocate action memory"); - return NULL; - } - pthread_mutex_lock(&hw->flows_lock); @@ -2763,13 +2756,12 @@ hns3_flow_action_create(struct rte_eth_dev *dev, counter->indirect = true; - handle->indirect_type = HNS3_INDIRECT_ACTION_TYPE_COUNT; - handle->counter_id = counter->id; + handle.indirect_type = HNS3_INDIRECT_ACTION_TYPE_COUNT; + handle.counter_id = counter->id; pthread_mutex_unlock(&hw->flows_lock); - return handle; + return (struct rte_flow_action_handle *)handle.val64; err_exit: pthread_mutex_unlock(&hw->flows_lock); - rte_free(handle); return NULL; } @@ -2781,9 +2773,11 @@ hns3_flow_action_destroy(struct rte_eth_dev *dev, { struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_flow_action_handle indir; struct hns3_flow_counter *counter; pthread_mutex_lock(&hw->flows_lock); - if (handle->indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) { + indir.val64 = (uint64_t)handle; + if (indir.indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) { pthread_mutex_unlock(&hw->flows_lock); return rte_flow_error_set(error, EINVAL, @@ -2792,5 +2786,5 @@ hns3_flow_action_destroy(struct rte_eth_dev *dev, } - counter = hns3_counter_lookup(dev, handle->counter_id); + counter = hns3_counter_lookup(dev, indir.counter_id); if (counter == NULL) { pthread_mutex_unlock(&hw->flows_lock); @@ -2807,6 +2801,5 @@ hns3_flow_action_destroy(struct rte_eth_dev *dev, } - (void)hns3_counter_release(dev, handle->counter_id); - rte_free(handle); + (void)hns3_counter_release(dev, indir.counter_id); pthread_mutex_unlock(&hw->flows_lock); @@ -2821,4 +2814,5 @@ hns3_flow_action_query(struct rte_eth_dev *dev, { struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_flow_action_handle indir; struct rte_flow flow; int ret; @@ -2826,5 +2820,6 @@ hns3_flow_action_query(struct rte_eth_dev *dev, pthread_mutex_lock(&hw->flows_lock); - if (handle->indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) { + indir.val64 = (uint64_t)handle; + if (indir.indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) { pthread_mutex_unlock(&hw->flows_lock); return rte_flow_error_set(error, EINVAL, @@ -2834,5 +2829,5 @@ hns3_flow_action_query(struct rte_eth_dev *dev, memset(&flow, 0, sizeof(flow)); - flow.counter_id = handle->counter_id; + flow.counter_id = indir.counter_id; ret = hns3_counter_query(dev, &flow, (struct rte_flow_query_count *)data, error); diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h index 1b49673f11..612890391d 100644 --- a/drivers/net/hns3/hns3_flow.h +++ b/drivers/net/hns3/hns3_flow.h @@ -51,6 +51,11 @@ enum { struct rte_flow_action_handle { - int indirect_type; - uint32_t counter_id; + union { + uint64_t val64; + struct { + int indirect_type; + uint32_t counter_id; + }; + }; }; -- 2.50.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-07-18 20:29:12.646322815 +0100 +++ 0044-net-hns3-fix-memory-leak-for-indirect-flow-action.patch 2025-07-18 20:29:10.923907310 +0100 @@ -1 +1 @@ -From 18596f7be8f93e159e98704af12b1cc8af289dd6 Mon Sep 17 00:00:00 2001 +From d3a09d4fef164931865774a0b3eb4ecd527156d3 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 18596f7be8f93e159e98704af12b1cc8af289dd6 ] + @@ -19 +20,0 @@ -Cc: stable@dpdk.org