From: Jens Axboe Date: Mon, 8 Dec 2008 14:03:12 +0000 (+0100) Subject: Make sure that the given CPU range is within the bounds of the OS X-Git-Tag: fio-1.24~31 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=19608d6ceb982409ba036f646c7c57671d2df779 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 --- 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