From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: "Stephen Hemminger" <stephen@networkplumber.org>,
jin.liu@corigine.com, stable@dpdk.org,
"Chaoyong He" <chaoyong.he@corigine.com>,
"Niklas Söderlund" <niklas.soderlund@corigine.com>,
"Peng Zhang" <peng.zhang@corigine.com>
Subject: [PATCH v2 01/43] net/nfp: fix use after free
Date: Sun, 24 Aug 2025 20:38:14 -0700 [thread overview]
Message-ID: <20250825034126.12046-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20250825034126.12046-1-stephen@networkplumber.org>
The code to cleanup metering was using the objects after calling
rte_free(). Fix by using LISTFOREACH_SAFE
Fixes: 2caf84a71cfd ("net/nfp: add meter options")
Cc: jin.liu@corigine.com
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/nfp/nfp_mtr.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/net/nfp/nfp_mtr.c b/drivers/net/nfp/nfp_mtr.c
index d4f2c4f2f0..4833ebd881 100644
--- a/drivers/net/nfp/nfp_mtr.c
+++ b/drivers/net/nfp/nfp_mtr.c
@@ -12,6 +12,13 @@
#include "flower/nfp_flower_representor.h"
#include "nfp_logs.h"
+#ifndef LIST_FOREACH_SAFE
+#define LIST_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = LIST_FIRST((head)); \
+ (var) && ((tvar) = LIST_NEXT((var), field), 1); \
+ (var) = (tvar))
+#endif
+
#define NFP_MAX_POLICY_CNT NFP_MAX_MTR_CNT
#define NFP_MAX_PROFILE_CNT NFP_MAX_MTR_CNT
@@ -1124,10 +1131,10 @@ nfp_mtr_priv_init(struct nfp_pf_dev *pf_dev)
void
nfp_mtr_priv_uninit(struct nfp_pf_dev *pf_dev)
{
- struct nfp_mtr *mtr;
+ struct nfp_mtr *mtr, *tmp_mtr;
struct nfp_mtr_priv *priv;
- struct nfp_mtr_policy *mtr_policy;
- struct nfp_mtr_profile *mtr_profile;
+ struct nfp_mtr_policy *mtr_policy, *tmp_policy;
+ struct nfp_mtr_profile *mtr_profile, *tmp_profile;
struct nfp_app_fw_flower *app_fw_flower;
app_fw_flower = NFP_PRIV_TO_APP_FW_FLOWER(pf_dev->app_fw_priv);
@@ -1135,17 +1142,17 @@ nfp_mtr_priv_uninit(struct nfp_pf_dev *pf_dev)
rte_eal_alarm_cancel(nfp_mtr_stats_request, (void *)app_fw_flower);
- LIST_FOREACH(mtr, &priv->mtrs, next) {
+ LIST_FOREACH_SAFE(mtr, &priv->mtrs, next, tmp_mtr) {
LIST_REMOVE(mtr, next);
rte_free(mtr);
}
- LIST_FOREACH(mtr_profile, &priv->profiles, next) {
+ LIST_FOREACH_SAFE(mtr_profile, &priv->profiles, next, tmp_profile) {
LIST_REMOVE(mtr_profile, next);
rte_free(mtr_profile);
}
- LIST_FOREACH(mtr_policy, &priv->policies, next) {
+ LIST_FOREACH_SAFE(mtr_policy, &priv->policies, next, tmp_policy) {
LIST_REMOVE(mtr_policy, next);
rte_free(mtr_policy);
}
--
2.47.2
next prev parent reply other threads:[~2025-08-25 3:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250818233102.180207-1-stephen@networkplumber.org>
2025-08-18 23:27 ` [RFC 02/47] " Stephen Hemminger
2025-08-18 23:27 ` [RFC 23/47] net/bnxt: remove use of sys/queue.h Stephen Hemminger
[not found] ` <20250825034126.12046-1-stephen@networkplumber.org>
2025-08-25 3:38 ` Stephen Hemminger [this message]
2025-08-25 3:38 ` [PATCH v2 15/43] " Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250825034126.12046-2-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=jin.liu@corigine.com \
--cc=niklas.soderlund@corigine.com \
--cc=peng.zhang@corigine.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).