patch 'test/red: fix some undefined behaviour' has been queued to stable release 24.11.5
luca.boccassi at gmail.com
luca.boccassi at gmail.com
Fri Feb 20 15:55:04 CET 2026
Hi,
FYI, your patch has been queued to stable release 24.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 02/22/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/bluca/dpdk-stable
This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/9e415142e0184f6bb97fb7827d7978affcba68b3
Thanks.
Luca Boccassi
---
>From 9e415142e0184f6bb97fb7827d7978affcba68b3 Mon Sep 17 00:00:00 2001
From: Bruce Richardson <bruce.richardson at intel.com>
Date: Thu, 11 Dec 2025 17:17:00 +0000
Subject: [PATCH] test/red: fix some undefined behaviour
[ upstream commit f904b818928931924f1f4a117d10d98617b92209 ]
The shift of a negative number (or very large positive) is undefined
behaviour which causes errors when run with UBSan. Fix this by making
the behaviour explicit for the edge case of n being zero in the
calculation.
Fixes: de3cfa2c9823 ("sched: initial import")
Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
Acked-by: Marat Khalili <marat.khalili at huawei.com>
---
lib/sched/rte_red.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/sched/rte_red.h b/lib/sched/rte_red.h
index e62abb9295..3b90cc46a9 100644
--- a/lib/sched/rte_red.h
+++ b/lib/sched/rte_red.h
@@ -172,8 +172,15 @@ __rte_red_calc_qempty_factor(uint8_t wq_log2, uint16_t m)
f = (n >> 6) & 0xf;
n >>= 10;
- if (n < RTE_RED_SCALING)
+ if (n < RTE_RED_SCALING) {
+ /* When n == 0, no rounding or shifting needed.
+ * For n > 0, add 2^(n-1) for rounding before right shift.
+ * This avoids UB from (1 << -1) when n == 0.
+ */
+ if (n == 0)
+ return (uint16_t) rte_red_pow2_frac_inv[f];
return (uint16_t) ((rte_red_pow2_frac_inv[f] + (1 << (n - 1))) >> n);
+ }
return 0;
}
--
2.47.3
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-02-20 14:55:43.460531175 +0000
+++ 0002-test-red-fix-some-undefined-behaviour.patch 2026-02-20 14:55:43.148190124 +0000
@@ -1 +1 @@
-From f904b818928931924f1f4a117d10d98617b92209 Mon Sep 17 00:00:00 2001
+From 9e415142e0184f6bb97fb7827d7978affcba68b3 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit f904b818928931924f1f4a117d10d98617b92209 ]
+
@@ -12 +13,0 @@
-Cc: stable at dpdk.org
More information about the stable
mailing list