patch 'examples/ntb: check more heap allocations' has been queued to stable release 24.11.3
Kevin Traynor
ktraynor at redhat.com
Fri Jul 18 21:31:32 CEST 2025
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/d7169bb15d919bf45d5857288173da87e8cf934d
Thanks.
Kevin
---
>From d7169bb15d919bf45d5857288173da87e8cf934d Mon Sep 17 00:00:00 2001
From: Bing Zhao <bingz at nvidia.com>
Date: Wed, 21 May 2025 20:23:33 +0300
Subject: [PATCH] examples/ntb: check more heap allocations
[ upstream commit 0c1a5ff96bfca1ac513b64f081a20f4992c6fcc0 ]
In some rare case, the libc memory heap allocation may fail and
return NULL pointer. Before accessing the memory via the pointer,
the NULL pointer check should be done to ensure the code locates
in the safe side and no crash.
Some newer GCC version will check this by default and report warning
on this. Adding the NULL pointer check will help to get rid of such
warning.
Fixes: 5194299d6ef5 ("examples/ntb: support more functions")
Signed-off-by: Bing Zhao <bingz at nvidia.com>
---
examples/ntb/ntb_fwd.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c
index 37d60208e3..33f3c1ef17 100644
--- a/examples/ntb/ntb_fwd.c
+++ b/examples/ntb/ntb_fwd.c
@@ -775,4 +775,8 @@ ntb_stats_clear(void)
}
ids = malloc(sizeof(uint32_t) * nb_ids);
+ if (ids == NULL) {
+ printf("Cannot allocate memory for statistics IDs\n");
+ return;
+ }
for (i = 0; i < nb_ids; i++)
ids[i] = i;
@@ -844,7 +848,18 @@ ntb_stats_display(void)
}
ids = malloc(sizeof(uint32_t) * nb_ids);
+ if (ids == NULL) {
+ printf("Cannot allocate memory for statistics IDs\n");
+ free(xstats_names);
+ return;
+ }
for (i = 0; i < nb_ids; i++)
ids[i] = i;
values = malloc(sizeof(uint64_t) * nb_ids);
+ if (values == NULL) {
+ printf("Cannot allocate memory to save fetching values\n");
+ free(xstats_names);
+ free(ids);
+ return;
+ }
if (nb_ids != rte_rawdev_xstats_get(dev_id, ids, values, nb_ids)) {
printf("Error: Unable to get xstats\n");
--
2.50.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2025-07-18 20:29:16.518690420 +0100
+++ 0158-examples-ntb-check-more-heap-allocations.patch 2025-07-18 20:29:11.156073403 +0100
@@ -1 +1 @@
-From 0c1a5ff96bfca1ac513b64f081a20f4992c6fcc0 Mon Sep 17 00:00:00 2001
+From d7169bb15d919bf45d5857288173da87e8cf934d Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 0c1a5ff96bfca1ac513b64f081a20f4992c6fcc0 ]
+
@@ -16 +17,0 @@
-Cc: stable at dpdk.org
More information about the stable
mailing list