patch 'test/red: fix some undefined behaviour' has been queued to stable release 25.11.1

Kevin Traynor ktraynor at redhat.com
Thu Feb 26 14:08:05 CET 2026


Hi,

FYI, your patch has been queued to stable release 25.11.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 03/02/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/fe83c00444cf170c5adc50ddd205afe2e16d46bc

Thanks.

Kevin

---
>From fe83c00444cf170c5adc50ddd205afe2e16d46bc 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
@@ -173,6 +173,13 @@ __rte_red_calc_qempty_factor(uint8_t wq_log2, uint16_t m)
 	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.53.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2026-02-26 10:16:47.328962944 +0000
+++ 0003-test-red-fix-some-undefined-behaviour.patch	2026-02-26 10:16:46.879458923 +0000
@@ -1 +1 @@
-From f904b818928931924f1f4a117d10d98617b92209 Mon Sep 17 00:00:00 2001
+From fe83c00444cf170c5adc50ddd205afe2e16d46bc 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