From: Michael Jeanson Date: Wed, 27 Jul 2022 14:54:53 +0000 (-0400) Subject: fix: removed accidental VLA in _get_num_possible_cpus() X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=feac72042ef1572189d4280a4f151ce049ac2b1e;p=lttng-ust.git fix: removed accidental VLA in _get_num_possible_cpus() The LTTNG_UST_PAGE_SIZE define can either point to a literal value or the sysconf() function making buf[] a VLA. Replace this by a cpumask specifc define that will always be a literal value. Change-Id: I8d329f314878e8018939f979861918969e3ec8ac Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- diff --git a/src/common/smp.c b/src/common/smp.c index d7ba23c4..980947cf 100644 --- a/src/common/smp.c +++ b/src/common/smp.c @@ -10,13 +10,13 @@ #include #include #include +#include #include #include #include #include -#include "common/align.h" #include "common/logging.h" #include "common/smp.h" @@ -190,11 +190,10 @@ error: static void _get_num_possible_cpus(void) { int ret; - int buf_len = LTTNG_UST_PAGE_SIZE; - char buf[buf_len]; + char buf[LTTNG_UST_CPUMASK_SIZE]; /* Get the possible cpu mask from sysfs, fallback to sysconf. */ - ret = get_possible_cpu_mask_from_sysfs((char *) &buf, buf_len); + ret = get_possible_cpu_mask_from_sysfs((char *) &buf, LTTNG_UST_CPUMASK_SIZE); if (ret <= 0) goto fallback; diff --git a/src/common/smp.h b/src/common/smp.h index b6dd5707..51fbd2d7 100644 --- a/src/common/smp.h +++ b/src/common/smp.h @@ -7,6 +7,8 @@ #ifndef _UST_COMMON_SMP_H #define _UST_COMMON_SMP_H +#define LTTNG_UST_CPUMASK_SIZE 4096 + /* * Get the CPU possible mask string from sysfs. *