[LTP] [PATCH v1 2/2] Prevent segmentation fault when negative task count specified
Marius Kittler
mkittler@suse.de
Tue Sep 12 16:43:51 CEST 2023
Signed-off-by: Marius Kittler <mkittler@suse.de>
---
testcases/realtime/func/rt-migrate/rt-migrate.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/testcases/realtime/func/rt-migrate/rt-migrate.c b/testcases/realtime/func/rt-migrate/rt-migrate.c
index 2554f63e2..252e77e6a 100644
--- a/testcases/realtime/func/rt-migrate/rt-migrate.c
+++ b/testcases/realtime/func/rt-migrate/rt-migrate.c
@@ -419,6 +419,10 @@ int main(int argc, char **argv)
numcpus = sysconf(_SC_NPROCESSORS_ONLN);
nr_tasks = numcpus + 1;
}
+ if (nr_tasks < 0) {
+ printf("The number of tasks must not be negative.\n");
+ exit(EXIT_FAILURE);
+ }
intervals = malloc(sizeof(stats_container_t) * nr_tasks);
if (!intervals)
--
2.42.0
More information about the ltp
mailing list