patch 'examples/flow_filtering: fix allocation error paths' has been queued to stable release 25.11.3

Kevin Traynor ktraynor at redhat.com
Thu Jul 30 11:16:31 CEST 2026


Hi,

FYI, your patch has been queued to stable release 25.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 08/04/26. 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/5446f51916359b05f8a5e04c450ece8b2196071c

Thanks.

Kevin

---
>From 5446f51916359b05f8a5e04c450ece8b2196071c Mon Sep 17 00:00:00 2001
From: Shani Peretz <shperetz at nvidia.com>
Date: Tue, 31 Mar 2026 15:53:47 +0300
Subject: [PATCH] examples/flow_filtering: fix allocation error paths

[ upstream commit 78688e13de9979175c876b1dd217913f265fd5ec ]

Add missing return statements after failed calloc NULL checks to
prevent null pointer dereferences.

Free previously allocated memory on error paths to prevent
leaked storage when a subsequent allocation fails.

Fixes: 3ebb8789136a ("examples/flow_filtering: add more snippets")

Signed-off-by: Shani Peretz <shperetz at nvidia.com>
---
 .../flow_filtering/snippets/snippet_match_gre.c     | 13 ++++++++++---
 .../flow_filtering/snippets/snippet_match_ipv4.c    | 13 ++++++++++---
 .../flow_filtering/snippets/snippet_match_mpls.c    |  8 ++++++--
 .../flow_filtering/snippets/snippet_match_nsh.c     | 13 ++++++++++---
 .../snippets/snippet_match_port_affinity.c          |  1 +
 .../snippets/snippet_match_roce_ib_bth.c            |  8 ++++++--
 .../snippets/snippet_switch_granularity.c           |  4 +++-
 7 files changed, 46 insertions(+), 14 deletions(-)

diff --git a/examples/flow_filtering/snippets/snippet_match_gre.c b/examples/flow_filtering/snippets/snippet_match_gre.c
index 477ec59451..f1638f38c5 100644
--- a/examples/flow_filtering/snippets/snippet_match_gre.c
+++ b/examples/flow_filtering/snippets/snippet_match_gre.c
@@ -22,6 +22,8 @@ snippet_match_gre_create_actions(__rte_unused uint16_t port_id, struct rte_flow_
 	/* Create one action that moves the packet to the selected queue. */
 	struct rte_flow_action_queue *queue = calloc(1, sizeof(struct rte_flow_action_queue));
-	if (queue == NULL)
+	if (queue == NULL) {
 		fprintf(stderr, "Failed to allocate memory for queue\n");
+		return;
+	}
 
 	/* Set the selected queue. */
@@ -41,10 +43,15 @@ snippet_match_gre_create_patterns(struct rte_flow_item *pattern)
 
 	gre_spec = calloc(1, sizeof(struct rte_flow_item_gre));
-	if (gre_spec == NULL)
+	if (gre_spec == NULL) {
 		fprintf(stderr, "Failed to allocate memory for gre_spec\n");
+		return;
+	}
 
 	gre_opt_spec = calloc(1, sizeof(struct rte_flow_item_gre_opt));
-	if (gre_opt_spec == NULL)
+	if (gre_opt_spec == NULL) {
 		fprintf(stderr, "Failed to allocate memory for gre_opt_spec\n");
+		free(gre_spec);
+		return;
+	}
 
 	/* Set the Checksum GRE option. */
diff --git a/examples/flow_filtering/snippets/snippet_match_ipv4.c b/examples/flow_filtering/snippets/snippet_match_ipv4.c
index 7f8aba66bb..6fcaacdc42 100644
--- a/examples/flow_filtering/snippets/snippet_match_ipv4.c
+++ b/examples/flow_filtering/snippets/snippet_match_ipv4.c
@@ -25,6 +25,8 @@ snippet_ipv4_flow_create_actions(__rte_unused uint16_t port_id, struct rte_flow_
 	 */
 	struct rte_flow_action_queue *queue = calloc(1, sizeof(struct rte_flow_action_queue));
-	if (queue == NULL)
+	if (queue == NULL) {
 		fprintf(stderr, "Failed to allocate memory for queue\n");
+		return;
+	}
 	queue->index = 1; /* The selected target queue.*/
 	action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE;
@@ -54,10 +56,15 @@ snippet_ipv4_flow_create_patterns(struct rte_flow_item *patterns)
 
 	ip_spec = calloc(1, sizeof(struct rte_flow_item_ipv4));
-	if (ip_spec == NULL)
+	if (ip_spec == NULL) {
 		fprintf(stderr, "Failed to allocate memory for ip_spec\n");
+		return;
+	}
 
 	ip_mask = calloc(1, sizeof(struct rte_flow_item_ipv4));
-	if (ip_mask == NULL)
+	if (ip_mask == NULL) {
 		fprintf(stderr, "Failed to allocate memory for ip_mask\n");
+		free(ip_spec);
+		return;
+	}
 
 	/* Match destination IP 192.168.1.1 with full mask */
diff --git a/examples/flow_filtering/snippets/snippet_match_mpls.c b/examples/flow_filtering/snippets/snippet_match_mpls.c
index 494a2d873d..0a54586c98 100644
--- a/examples/flow_filtering/snippets/snippet_match_mpls.c
+++ b/examples/flow_filtering/snippets/snippet_match_mpls.c
@@ -26,6 +26,8 @@ snippet_mpls_create_actions(__rte_unused uint16_t port_id, struct rte_flow_actio
 
 	queue = calloc(1, sizeof(struct rte_flow_item_ipv4));
-	if (queue == NULL)
+	if (queue == NULL) {
 		fprintf(stderr, "Failed to allocate memory for queue\n");
+		return;
+	}
 
 	/* Set the selected queue. */
@@ -44,6 +46,8 @@ snippet_mpls_create_patterns(struct rte_flow_item *pattern)
 
 	mpls_item = calloc(1, sizeof(struct rte_flow_item_ipv4));
-	if (mpls_item == NULL)
+	if (mpls_item == NULL) {
 		fprintf(stderr, "Failed to allocate memory for mpls_item\n");
+		return;
+	}
 
 	memcpy(mpls_item->label_tc_s, "\xab\xcd\xe1", sizeof(mpls_item->label_tc_s));
diff --git a/examples/flow_filtering/snippets/snippet_match_nsh.c b/examples/flow_filtering/snippets/snippet_match_nsh.c
index 262d0c8d81..6a8ac5b942 100644
--- a/examples/flow_filtering/snippets/snippet_match_nsh.c
+++ b/examples/flow_filtering/snippets/snippet_match_nsh.c
@@ -26,6 +26,8 @@ snippet_match_nsh_create_actions(uint16_t port_id, struct rte_flow_action *actio
 
 	struct rte_flow_action_port_id *portid = calloc(1, sizeof(struct rte_flow_action_port_id));
-	if (portid == NULL)
+	if (portid == NULL) {
 		fprintf(stderr, "Failed to allocate memory for port_id\n");
+		return;
+	}
 
 	/* To match on NSH to port_id 1. */
@@ -44,10 +46,15 @@ snippet_match_nsh_create_patterns(struct rte_flow_item *pattern)
 
 	spec = calloc(1, sizeof(struct rte_flow_item_udp));
-	if (spec == NULL)
+	if (spec == NULL) {
 		fprintf(stderr, "Failed to allocate memory for spec\n");
+		return;
+	}
 
 	mask = calloc(1, sizeof(struct rte_flow_item_udp));
-	if (mask == NULL)
+	if (mask == NULL) {
 		fprintf(stderr, "Failed to allocate memory for mask\n");
+		free(spec);
+		return;
+	}
 
 	/* Set the patterns. */
diff --git a/examples/flow_filtering/snippets/snippet_match_port_affinity.c b/examples/flow_filtering/snippets/snippet_match_port_affinity.c
index 3709121173..a7fb8a49b4 100644
--- a/examples/flow_filtering/snippets/snippet_match_port_affinity.c
+++ b/examples/flow_filtering/snippets/snippet_match_port_affinity.c
@@ -87,4 +87,5 @@ snippet_match_port_affinity_create_patterns(struct rte_flow_item *pattern)
 	if (affinity_mask == NULL) {
 		fprintf(stderr, "Failed to allocate memory for affinity_mask\n");
+		free(affinity_spec);
 		return;
 	}
diff --git a/examples/flow_filtering/snippets/snippet_match_roce_ib_bth.c b/examples/flow_filtering/snippets/snippet_match_roce_ib_bth.c
index f3c7e3eb70..6714fa734e 100644
--- a/examples/flow_filtering/snippets/snippet_match_roce_ib_bth.c
+++ b/examples/flow_filtering/snippets/snippet_match_roce_ib_bth.c
@@ -27,6 +27,8 @@ snippet_match_roce_ib_bth_create_actions(uint16_t port_id, struct rte_flow_actio
 	/* Create one action that moves the packet to the selected queue. */
 	struct rte_flow_action_queue *queue = calloc(1, sizeof(struct rte_flow_action_queue));
-	if (queue == NULL)
+	if (queue == NULL) {
 		fprintf(stderr, "Failed to allocate memory for queue\n");
+		return;
+	}
 
 	/* Set the selected queue. */
@@ -45,6 +47,8 @@ snippet_match_roce_ib_bth_create_patterns(struct rte_flow_item *pattern)
 
 	bth = calloc(1, sizeof(struct rte_flow_item_ib_bth));
-	if (bth == NULL)
+	if (bth == NULL) {
 		fprintf(stderr, "Failed to allocate memory for bth\n");
+		return;
+	}
 
 	bth->hdr.opcode = 0x81;
diff --git a/examples/flow_filtering/snippets/snippet_switch_granularity.c b/examples/flow_filtering/snippets/snippet_switch_granularity.c
index 414870bf89..a6b40e8d90 100644
--- a/examples/flow_filtering/snippets/snippet_switch_granularity.c
+++ b/examples/flow_filtering/snippets/snippet_switch_granularity.c
@@ -28,6 +28,8 @@ snippet_match_switch_granularity_create_actions(uint16_t port_id, struct rte_flo
 	struct rte_flow_action_ethdev *represented_port = calloc(1,
 		sizeof(struct rte_flow_action_ethdev));
-	if (represented_port == NULL)
+	if (represented_port == NULL) {
 		fprintf(stderr, "Failed to allocate memory for represented_port\n");
+		return;
+	}
 
 	represented_port->port_id = 0;
-- 
2.55.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2026-07-30 10:16:02.988603727 +0100
+++ 0052-examples-flow_filtering-fix-allocation-error-paths.patch	2026-07-30 10:16:01.486307752 +0100
@@ -1 +1 @@
-From 78688e13de9979175c876b1dd217913f265fd5ec Mon Sep 17 00:00:00 2001
+From 5446f51916359b05f8a5e04c450ece8b2196071c Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 78688e13de9979175c876b1dd217913f265fd5ec ]
+
@@ -13 +14,0 @@
-Cc: stable at dpdk.org
@@ -17,16 +18,8 @@
- .../snippets/snippet_match_gre.c              | 13 +++++++---
- .../snippets/snippet_match_integrity_flags.c  | 26 +++++++++++++++----
- .../snippets/snippet_match_ipv4.c             | 13 +++++++---
- .../snippets/snippet_match_mpls.c             |  8 ++++--
- .../snippets/snippet_match_nsh.c              | 13 +++++++---
- .../snippets/snippet_match_nvgre.c            | 26 +++++++++++++++----
- .../snippets/snippet_match_packet_type.c      | 13 +++++++---
- .../snippets/snippet_match_port_affinity.c    |  1 +
- .../snippets/snippet_match_roce_ib_bth.c      |  8 ++++--
- .../snippets/snippet_match_vxlan_gbp.c        | 13 +++++++---
- .../snippets/snippet_match_vxlan_gpe.c        |  8 ++++--
- .../snippets/snippet_modify_ecn.c             |  9 +++++--
- .../flow_filtering/snippets/snippet_nat64.c   | 10 +++++++
- .../snippets/snippet_random_match.c           |  8 ++++--
- .../snippets/snippet_switch_granularity.c     |  4 ++-
- 15 files changed, 137 insertions(+), 36 deletions(-)
+ .../flow_filtering/snippets/snippet_match_gre.c     | 13 ++++++++++---
+ .../flow_filtering/snippets/snippet_match_ipv4.c    | 13 ++++++++++---
+ .../flow_filtering/snippets/snippet_match_mpls.c    |  8 ++++++--
+ .../flow_filtering/snippets/snippet_match_nsh.c     | 13 ++++++++++---
+ .../snippets/snippet_match_port_affinity.c          |  1 +
+ .../snippets/snippet_match_roce_ib_bth.c            |  8 ++++++--
+ .../snippets/snippet_switch_granularity.c           |  4 +++-
+ 7 files changed, 46 insertions(+), 14 deletions(-)
@@ -66,57 +58,0 @@
-diff --git a/examples/flow_filtering/snippets/snippet_match_integrity_flags.c b/examples/flow_filtering/snippets/snippet_match_integrity_flags.c
-index 0f05c902b9..3d37b5f2a5 100644
---- a/examples/flow_filtering/snippets/snippet_match_integrity_flags.c
-+++ b/examples/flow_filtering/snippets/snippet_match_integrity_flags.c
-@@ -21,6 +21,8 @@ snippet_match_integrity_flags_create_actions(__rte_unused uint16_t port_id,
- 	/* Create one action that moves the packet to the selected queue. */
- 	struct rte_flow_action_queue *queue = calloc(1, sizeof(struct rte_flow_action_queue));
--	if (queue == NULL)
-+	if (queue == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for queue\n");
-+		return;
-+	}
- 
- 	queue->index = 1;
-@@ -39,6 +41,8 @@ snippet_match_integrity_flags_create_patterns(struct rte_flow_item *pattern)
- 
- 	integrity_spec = calloc(1, sizeof(struct rte_flow_item_integrity));
--	if (integrity_spec == NULL)
-+	if (integrity_spec == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for integrity_spec\n");
-+		return;
-+	}
- 
- 	integrity_spec->level = 0;
-@@ -47,6 +51,9 @@ snippet_match_integrity_flags_create_patterns(struct rte_flow_item *pattern)
- 
- 	integrity_mask = calloc(1, sizeof(struct rte_flow_item_integrity));
--	if (integrity_mask == NULL)
-+	if (integrity_mask == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for integrity_mask\n");
-+		free(integrity_spec);
-+		return;
-+	}
- 
- 	integrity_mask->level = 0;
-@@ -56,10 +63,19 @@ snippet_match_integrity_flags_create_patterns(struct rte_flow_item *pattern)
- 
- 	ip_spec = calloc(1, sizeof(struct rte_flow_item_ipv4));
--	if (ip_spec == NULL)
-+	if (ip_spec == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for ip_spec\n");
-+		free(integrity_spec);
-+		free(integrity_mask);
-+		return;
-+	}
- 
- 	ip_mask = calloc(1, sizeof(struct rte_flow_item_ipv4));
--	if (ip_mask == NULL)
-+	if (ip_mask == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for ip_mask\n");
-+		free(integrity_spec);
-+		free(integrity_mask);
-+		free(ip_spec);
-+		return;
-+	}
- 
- 	ip_spec->hdr.dst_addr = htonl(((192<<24) + (168<<16) + (1<<8) + 1));
@@ -211,86 +146,0 @@
-diff --git a/examples/flow_filtering/snippets/snippet_match_nvgre.c b/examples/flow_filtering/snippets/snippet_match_nvgre.c
-index 4ae06c5f1a..3ed62db4a2 100644
---- a/examples/flow_filtering/snippets/snippet_match_nvgre.c
-+++ b/examples/flow_filtering/snippets/snippet_match_nvgre.c
-@@ -24,6 +24,8 @@ snippet_match_nvgre_create_actions(uint16_t port_id, struct rte_flow_action *act
- 
- 	struct rte_flow_action_queue *queue = calloc(1, sizeof(struct rte_flow_action_queue));
--	if (queue == NULL)
-+	if (queue == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for queue\n");
-+		return;
-+	}
- 	queue->index = 1;
- 
-@@ -37,18 +39,32 @@ snippet_match_nvgre_create_patterns(struct rte_flow_item *pattern)
- {
- 	struct rte_flow_item_nvgre *nvgre = calloc(1, sizeof(struct rte_flow_item_nvgre));
--	if (nvgre == NULL)
-+	if (nvgre == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for nvgre\n");
-+		return;
-+	}
- 
- 	struct rte_flow_item_udp *udp = calloc(1, sizeof(struct rte_flow_item_udp));
--	if (udp == NULL)
-+	if (udp == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for udp\n");
-+		free(nvgre);
-+		return;
-+	}
- 
- 	struct rte_flow_item_nvgre *nvgre_mask = calloc(1, sizeof(struct rte_flow_item_nvgre));
--	if (nvgre_mask == NULL)
-+	if (nvgre_mask == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for nvgre_mask\n");
-+		free(nvgre);
-+		free(udp);
-+		return;
-+	}
- 
- 	struct rte_flow_item_udp *udp_mask = calloc(1, sizeof(struct rte_flow_item_udp));
--	if (udp_mask == NULL)
-+	if (udp_mask == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for udp_mask\n");
-+		free(nvgre);
-+		free(udp);
-+		free(nvgre_mask);
-+		return;
-+	}
- 
- 	/* build rule to match specific NVGRE:
-diff --git a/examples/flow_filtering/snippets/snippet_match_packet_type.c b/examples/flow_filtering/snippets/snippet_match_packet_type.c
-index 3b16d4b0ab..97c0a88f3d 100644
---- a/examples/flow_filtering/snippets/snippet_match_packet_type.c
-+++ b/examples/flow_filtering/snippets/snippet_match_packet_type.c
-@@ -21,6 +21,8 @@ snippet_match_packet_type_create_actions(__rte_unused uint16_t port_id,
- 	/* Create one action that moves the packet to the selected queue. */
- 	struct rte_flow_action_queue *queue = calloc(1, sizeof(struct rte_flow_action_queue));
--	if (queue == NULL)
-+	if (queue == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for queue\n");
-+		return;
-+	}
- 
- 	/*
-@@ -39,6 +41,8 @@ snippet_match_packet_type_create_patterns(struct rte_flow_item *pattern)
- 	struct rte_flow_item_ptype *ptype_spec;
- 	ptype_spec = calloc(1, sizeof(struct rte_flow_item_ptype));
--	if (ptype_spec == NULL)
-+	if (ptype_spec == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for ptype_spec\n");
-+		return;
-+	}
- 
- 	ptype_spec->packet_type = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP;
-@@ -46,6 +50,9 @@ snippet_match_packet_type_create_patterns(struct rte_flow_item *pattern)
- 	struct rte_flow_item_ptype *ptype_mask;
- 	ptype_mask = calloc(1, sizeof(struct rte_flow_item_ptype));
--	if (ptype_mask == NULL)
-+	if (ptype_mask == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for ptype_mask\n");
-+		free(ptype_spec);
-+		return;
-+	}
- 
- 	ptype_mask->packet_type = RTE_PTYPE_L3_MASK | RTE_PTYPE_L4_MASK;
@@ -331,123 +180,0 @@
-diff --git a/examples/flow_filtering/snippets/snippet_match_vxlan_gbp.c b/examples/flow_filtering/snippets/snippet_match_vxlan_gbp.c
-index 521e9aae94..ccd66f8d44 100644
---- a/examples/flow_filtering/snippets/snippet_match_vxlan_gbp.c
-+++ b/examples/flow_filtering/snippets/snippet_match_vxlan_gbp.c
-@@ -22,6 +22,8 @@ snippet_match_vxlan_gbp_create_actions(__rte_unused uint16_t port_id,
- {
- 	struct rte_flow_action_queue *queue = calloc(1, sizeof(struct rte_flow_action_queue));
--	if (queue == NULL)
-+	if (queue == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for queue\n");
-+		return;
-+	}
- 
- 	queue->index = 1;
-@@ -36,10 +38,15 @@ snippet_match_vxlan_gbp_create_patterns(struct rte_flow_item *pattern)
- {
- 	struct rte_flow_item_vxlan *vxlan_gbp = calloc(1, sizeof(struct rte_flow_item_vxlan));
--	if (vxlan_gbp == NULL)
-+	if (vxlan_gbp == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for vxlan_gbp\n");
-+		return;
-+	}
- 
- 	struct rte_flow_item_vxlan *vxlan_gbp_mask = calloc(1, sizeof(struct rte_flow_item_vxlan));
--	if (vxlan_gbp_mask == NULL)
-+	if (vxlan_gbp_mask == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for vxlan_gbp_mask\n");
-+		free(vxlan_gbp);
-+		return;
-+	}
- 
- 	uint8_t vni[] = {0x00, 0x00, 0x00};
-diff --git a/examples/flow_filtering/snippets/snippet_match_vxlan_gpe.c b/examples/flow_filtering/snippets/snippet_match_vxlan_gpe.c
-index 08c71a58e0..62b70ba5c9 100644
---- a/examples/flow_filtering/snippets/snippet_match_vxlan_gpe.c
-+++ b/examples/flow_filtering/snippets/snippet_match_vxlan_gpe.c
-@@ -24,6 +24,8 @@ snippet_match_vxlan_gpe_create_actions(uint16_t port_id, struct rte_flow_action
- 
- 	struct rte_flow_action_queue *queue = calloc(1, sizeof(struct rte_flow_action_queue));
--	if (queue == NULL)
-+	if (queue == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for queue\n");
-+		return;
-+	}
- 	queue->index = 1;
- 
-@@ -38,6 +40,8 @@ snippet_match_vxlan_gpe_create_patterns(struct rte_flow_item *pattern)
- 	struct rte_flow_item_vxlan_gpe *vxlan_gpe_mask = calloc(1,
- 		sizeof(struct rte_flow_item_vxlan_gpe));
--	if (vxlan_gpe_mask == NULL)
-+	if (vxlan_gpe_mask == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for vxlan_gpe_mask\n");
-+		return;
-+	}
- 	memset(vxlan_gpe_mask->hdr.vni, 0xff, 3);
- 
-diff --git a/examples/flow_filtering/snippets/snippet_modify_ecn.c b/examples/flow_filtering/snippets/snippet_modify_ecn.c
-index 74bc708036..563a394dc6 100644
---- a/examples/flow_filtering/snippets/snippet_modify_ecn.c
-+++ b/examples/flow_filtering/snippets/snippet_modify_ecn.c
-@@ -23,11 +23,16 @@ snippet_match_modify_ecn_create_actions(__rte_unused uint16_t port_id,
- 	/* Create one action that moves the packet to the selected queue. */
- 	struct rte_flow_action_queue *queue = calloc(1, sizeof(struct rte_flow_action_queue));
--	if (queue == NULL)
-+	if (queue == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for queue\n");
-+		return;
-+	}
- 
- 	struct rte_flow_action_modify_field *modify_field =
- 					calloc(1, sizeof(struct rte_flow_action_modify_field));
--	if (modify_field == NULL)
-+	if (modify_field == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for modify_field\n");
-+		free(queue);
-+		return;
-+	}
- 
- 	queue->index = 1;
-diff --git a/examples/flow_filtering/snippets/snippet_nat64.c b/examples/flow_filtering/snippets/snippet_nat64.c
-index 5c87abb3be..2190a625fd 100644
---- a/examples/flow_filtering/snippets/snippet_nat64.c
-+++ b/examples/flow_filtering/snippets/snippet_nat64.c
-@@ -24,5 +24,15 @@ snippet_match_nat64_create_actions(uint16_t port_id, struct rte_flow_action *act
- 
- 	struct rte_flow_action_nat64 *nat64_v = calloc(1, sizeof(struct rte_flow_action_nat64));
-+	if (nat64_v == NULL) {
-+		fprintf(stderr, "Failed to allocate memory for nat64_v\n");
-+		return;
-+	}
-+
- 	struct rte_flow_action_jump *jump_v = calloc(1, sizeof(struct rte_flow_action_jump));
-+	if (jump_v == NULL) {
-+		fprintf(stderr, "Failed to allocate memory for jump_v\n");
-+		free(nat64_v);
-+		return;
-+	}
- 
- 	nat64_v->type = RTE_FLOW_NAT64_4TO6;
-diff --git a/examples/flow_filtering/snippets/snippet_random_match.c b/examples/flow_filtering/snippets/snippet_random_match.c
-index 60e252a6ca..36adfdfa6b 100644
---- a/examples/flow_filtering/snippets/snippet_random_match.c
-+++ b/examples/flow_filtering/snippets/snippet_random_match.c
-@@ -21,6 +21,8 @@ snippet_match_random_value_create_actions(__rte_unused uint16_t port_id,
- {
- 	struct rte_flow_action_queue *queue = calloc(1, sizeof(struct rte_flow_action_queue));
--	if (queue == NULL)
-+	if (queue == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for queue\n");
-+		return;
-+	}
- 	queue->index = UINT16_MAX; /* The selected target queue.*/
- 	action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE;
-@@ -34,6 +36,8 @@ snippet_match_random_value_create_patterns(struct rte_flow_item *pattern)
- 	struct rte_flow_item_random *random_item;
- 	random_item = calloc(1, sizeof(struct rte_flow_item_random));
--	if (random_item == NULL)
-+	if (random_item == NULL) {
- 		fprintf(stderr, "Failed to allocate memory for port_representor_spec\n");
-+		return;
-+	}
- 
- 	random_item->value = 0;



More information about the stable mailing list