public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
To: libc-alpha@sourceware.org
Subject: [PATCH v3] linux: __get_nprocs_sched: do not feed CPU_COUNT_S with garbage [BZ #28850]
Date: Tue,  1 Feb 2022 22:44:46 +0000	[thread overview]
Message-ID: <20220201224446.547264-1-glebfm@altlinux.org> (raw)
In-Reply-To: <87a6fa2p4c.fsf@igel.home>

Pass the actual number of bytes returned by the kernel.

Fixes: 33099d72e41c ("linux: Simplify get_nprocs")
---
 sysdeps/unix/sysv/linux/getsysstats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index 4798cc337e..c98c8ce3d4 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -44,7 +44,7 @@ __get_nprocs_sched (void)
   int r = INTERNAL_SYSCALL_CALL (sched_getaffinity, 0, cpu_bits_size,
 				 cpu_bits);
   if (r > 0)
-    return CPU_COUNT_S (cpu_bits_size, (cpu_set_t*) cpu_bits);
+    return CPU_COUNT_S (r, (cpu_set_t*) cpu_bits);
   else if (r == -EINVAL)
     /* The input buffer is still not enough to store the number of cpus.  This
        is an arbitrary values assuming such systems should be rare and there
-- 
glebfm


  reply	other threads:[~2022-02-01 22:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01 21:56 [PATCH] linux: __get_nprocs_sched: initialize cpu_bits array with zeroes " Gleb Fotengauer-Malinovskiy
2022-02-01 22:14 ` [PATCH v2] " Gleb Fotengauer-Malinovskiy
2022-02-01 22:22   ` Dmitry V. Levin
2022-02-01 22:33   ` Andreas Schwab
2022-02-01 22:44     ` Gleb Fotengauer-Malinovskiy [this message]
2022-02-01 22:46       ` [PATCH v3] linux: __get_nprocs_sched: do not feed CPU_COUNT_S with garbage " Dmitry V. Levin
2022-02-01 22:14 ` [PATCH] linux: __get_nprocs_sched: initialize cpu_bits array with zeroes " Dmitry V. Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220201224446.547264-1-glebfm@altlinux.org \
    --to=glebfm@altlinux.org \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).