patch 'examples/ntb: check more heap allocations' has been queued to stable release 23.11.5
Xueming Li
xuemingl at nvidia.com
Wed Jul 30 16:56:32 CEST 2025
Hi,
FYI, your patch has been queued to stable release 23.11.5
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/10/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://git.dpdk.org/dpdk-stable/log/?h=23.11-staging
This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=bf7357a972228374eb9146ad5870b21fb95f034b
Thanks.
Xueming Li <xuemingl at nvidia.com>
---
>From bf7357a972228374eb9146ad5870b21fb95f034b 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
Cc: Xueming Li <xuemingl at nvidia.com>
[ 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")
Cc: stable at dpdk.org
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 fcf0ec9b56..9a43ca4a3e 100644
--- a/examples/ntb/ntb_fwd.c
+++ b/examples/ntb/ntb_fwd.c
@@ -774,6 +774,10 @@ ntb_stats_clear(void)
return;
}
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;
rte_rawdev_xstats_reset(dev_id, ids, nb_ids);
@@ -843,9 +847,20 @@ ntb_stats_display(void)
return;
}
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");
free(xstats_names);
--
2.34.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2025-07-30 22:50:04.553107618 +0800
+++ 0023-examples-ntb-check-more-heap-allocations.patch 2025-07-30 22:50:03.096766566 +0800
@@ -1 +1 @@
-From 0c1a5ff96bfca1ac513b64f081a20f4992c6fcc0 Mon Sep 17 00:00:00 2001
+From bf7357a972228374eb9146ad5870b21fb95f034b Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 0c1a5ff96bfca1ac513b64f081a20f4992c6fcc0 ]
@@ -24 +27 @@
-index 37d60208e3..33f3c1ef17 100644
+index fcf0ec9b56..9a43ca4a3e 100644
More information about the stable
mailing list