[v2] linux: __get_nprocs_sched: initialize cpu_bits array with zeroes [BZ #28850]
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
dj/TryBot-32bit |
success
|
Build for i686
|
Commit Message
---
sysdeps/unix/sysv/linux/getsysstats.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Tue, Feb 01, 2022 at 10:14:07PM +0000, Gleb Fotengauer-Malinovskiy wrote:
> ---
> sysdeps/unix/sysv/linux/getsysstats.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
> index 4798cc337e..b0a7663f56 100644
> --- a/sysdeps/unix/sysv/linux/getsysstats.c
> +++ b/sysdeps/unix/sysv/linux/getsysstats.c
> @@ -41,6 +41,7 @@ __get_nprocs_sched (void)
>
> /* This cannot use malloc because it is used on malloc initialization. */
> __cpu_mask cpu_bits[cpu_bits_size / sizeof (__cpu_mask)];
> + CPU_ZERO_S (cpu_bits_size, (cpu_set_t*) cpu_bits);
> int r = INTERNAL_SYSCALL_CALL (sched_getaffinity, 0, cpu_bits_size,
> cpu_bits);
> if (r > 0)
Fixes: 33099d72e41c ("linux: Simplify get_nprocs")
Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
On Feb 01 2022, Gleb Fotengauer-Malinovskiy wrote:
> ---
> sysdeps/unix/sysv/linux/getsysstats.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
> index 4798cc337e..b0a7663f56 100644
> --- a/sysdeps/unix/sysv/linux/getsysstats.c
> +++ b/sysdeps/unix/sysv/linux/getsysstats.c
> @@ -41,6 +41,7 @@ __get_nprocs_sched (void)
>
> /* This cannot use malloc because it is used on malloc initialization. */
> __cpu_mask cpu_bits[cpu_bits_size / sizeof (__cpu_mask)];
> + CPU_ZERO_S (cpu_bits_size, (cpu_set_t*) cpu_bits);
> int r = INTERNAL_SYSCALL_CALL (sched_getaffinity, 0, cpu_bits_size,
> cpu_bits);
> if (r > 0)
r is the actual size of the cpu mask, which can conveniently be passed
to CPU_COUNT_S.
@@ -41,6 +41,7 @@ __get_nprocs_sched (void)
/* This cannot use malloc because it is used on malloc initialization. */
__cpu_mask cpu_bits[cpu_bits_size / sizeof (__cpu_mask)];
+ CPU_ZERO_S (cpu_bits_size, (cpu_set_t*) cpu_bits);
int r = INTERNAL_SYSCALL_CALL (sched_getaffinity, 0, cpu_bits_size,
cpu_bits);
if (r > 0)