From 6e0fb96303bb432b173632b94c53a24f1301a784 Mon Sep 17 00:00:00 2001 From: John Kacur Date: Thu, 18 Nov 2021 14:40:09 -0500 Subject: [PATCH] rt-tests: deadline_tests: Null check to prevent floating point exception Resolves:rhbz#2023501 Signed-off-by: John Kacur --- realtime-tests.spec | 8 ++++- ...ests-Null-check-to-prevent-exception.patch | 34 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 rt-tests-deadline_tests-Null-check-to-prevent-exception.patch diff --git a/realtime-tests.spec b/realtime-tests.spec index 5ffaaf5..b3c5b46 100644 --- a/realtime-tests.spec +++ b/realtime-tests.spec @@ -6,7 +6,7 @@ Name: realtime-tests # Numa argument to make: NUMA=1 # Version: 2.1 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 URL: https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git Source0: https://www.kernel.org/pub/linux/utils/rt-tests/rt-tests-%{version}.tar.xz @@ -23,6 +23,7 @@ Requires: bc Patch1: sched_deadline-Accommodate-new-location-of-HRTICK-file.patch Patch2: sched_deadline-Use-HRTICK_DL-for-sched_deadline-tests.patch Patch3: rt-tests-Add-missing-option-F-to-optstring.patch +Patch4: rt-tests-deadline_tests-Null-check-to-prevent-exception.patch %description realtime-tests is a set of programs that test and measure various components of @@ -34,6 +35,7 @@ latency. It also tests the functioning of priority-inheritance mutexes. %patch1 -p1 %patch2 -p1 %patch3 -p1 +%patch4 -p1 %build %set_build_flags @@ -84,6 +86,10 @@ latency. It also tests the functioning of priority-inheritance mutexes. %{_mandir}/man8/determine_maximum_mpps.8.* %changelog +* Thu Nov 18 2021 John Kacur - 2.1-5 +- Null check to prevent floating point exception in deadline test +Resolves: rhbz#2023501 + * Tue Nov 02 2021 Leah Leshchinsky - 2.1-4 - Add missing option -F to optstring Resolved: rhbz#2007021 diff --git a/rt-tests-deadline_tests-Null-check-to-prevent-exception.patch b/rt-tests-deadline_tests-Null-check-to-prevent-exception.patch new file mode 100644 index 0000000..76fe329 --- /dev/null +++ b/rt-tests-deadline_tests-Null-check-to-prevent-exception.patch @@ -0,0 +1,34 @@ +From 6a3dd40539c1804db8b1fe1684afa5fa111636fe Mon Sep 17 00:00:00 2001 +From: John Kacur +Date: Thu, 11 Nov 2021 08:56:54 -0500 +Subject: [PATCH] rt-tests: deadline_tests: Null check to prevent floating + point exception + +Fix a floating point exception that can occur if sd->nr_adjust is 0 +by checking it before performing a division by zero. + +Signed-off-by: John Kacur +--- + src/sched_deadline/deadline_test.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c +index 53abd4d2ca6b..b7e1e045b57c 100644 +--- a/src/sched_deadline/deadline_test.c ++++ b/src/sched_deadline/deadline_test.c +@@ -2050,8 +2050,10 @@ int main(int argc, char **argv) + printf("missed deadlines = %d\n", sd->missed_deadlines); + printf("missed periods = %d\n", sd->missed_periods); + printf("Total adjustments = %lld us\n", sd->total_adjust); +- printf("# adjustments = %lld avg: %lld us\n", +- sd->nr_adjust, sd->total_adjust / sd->nr_adjust); ++ if (sd->nr_adjust) { ++ printf("# adjustments = %lld avg: %lld us\n", ++ sd->nr_adjust, sd->total_adjust / sd->nr_adjust); ++ } + printf("deadline : %lld us\n", sd->deadline_us); + printf("runtime : %lld us\n", sd->runtime_us); + printf("nr_periods : %lld\n", sd->nr_periods); +-- +2.31.1 +