From 19608d6ceb982409ba036f646c7c57671d2df779 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 8 Dec 2008 15:03:12 +0100 Subject: [PATCH] Make sure that the given CPU range is within the bounds of the OS glibc provides CPU_SETSIZE as the maximum CPU count. Signed-off-by: Jens Axboe --- options.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/options.c b/options.c index 5bbeb342..c99f102d 100644 --- a/options.c +++ b/options.c @@ -264,6 +264,7 @@ static int str_cpus_allowed_cb(void *data, const char *input) { struct thread_data *td = data; char *cpu, *str, *p; + int ret = 0; CPU_ZERO(&td->o.cpumask); @@ -292,15 +293,25 @@ static int str_cpus_allowed_cb(void *data, const char *input) if (icpu2 == -1) icpu2 = icpu; while (icpu <= icpu2) { + if (icpu >= CPU_SETSIZE) { + log_err("fio: your OS only supports up to" + " %d CPUs\n", (int) CPU_SETSIZE); + ret = 1; + break; + } + dprint(FD_PARSE, "set cpu allowed %d\n", icpu); CPU_SET(atoi(cpu), &td->o.cpumask); icpu++; } + if (ret) + break; } free(p); - td->o.cpumask_set = 1; - return 0; + if (!ret) + td->o.cpumask_set = 1; + return ret; } #endif -- 2.25.1