From: Feng Tang <feng.tang@linux.alibaba.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Petr Mladek <pmladek@suse.com>,
Steven Rostedt <rostedt@goodmis.org>,
Lance Yang <lance.yang@linux.dev>,
Jonathan Corbet <corbet@lwn.net>,
linux-kernel@vger.kernel.org
Cc: Askar Safin <safinaskar@zohomail.com>,
paulmck@kernel.org, john.ogness@linutronix.de,
Feng Tang <feng.tang@linux.alibaba.com>
Subject: [PATCH v2 1/4] lib/sys_info: handle sys_info_mask==0 case
Date: Mon, 25 Aug 2025 10:56:58 +0800 [thread overview]
Message-ID: <20250825025701.81921-2-feng.tang@linux.alibaba.com> (raw)
In-Reply-To: <20250825025701.81921-1-feng.tang@linux.alibaba.com>
It is a normal case that bitmask parameter is 0, so pre-initialize the
names[] to null string to cover this case.
Also remove the superfluous "+1" in names[sizeof(sys_info_avail) + 1],
which is needed for 'strlen()', but not for 'sizeof()'.
Suggested-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
---
lib/sys_info.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/sys_info.c b/lib/sys_info.c
index 5bf503fd7ec1..496f9151c9b6 100644
--- a/lib/sys_info.c
+++ b/lib/sys_info.c
@@ -55,7 +55,7 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,
void *buffer, size_t *lenp,
loff_t *ppos)
{
- char names[sizeof(sys_info_avail) + 1];
+ char names[sizeof(sys_info_avail)];
struct ctl_table table;
unsigned long *si_bits_global;
@@ -81,6 +81,7 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,
char *delim = "";
int i, len = 0;
+ names[0] = '\0';
for (i = 0; i < ARRAY_SIZE(si_names); i++) {
if (*si_bits_global & si_names[i].bit) {
len += scnprintf(names + len, sizeof(names) - len,
--
2.39.5 (Apple Git-154)
next prev parent reply other threads:[~2025-08-25 2:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-25 2:56 [PATCH v2 0/4] follow up patches for panic_print's generalization Feng Tang
2025-08-25 2:56 ` Feng Tang [this message]
2025-08-25 2:56 ` [PATCH v2 2/4] panic: refine the document for 'panic_print' Feng Tang
2025-08-25 2:57 ` [PATCH v2 3/4] panic: add note that 'panic_print' parameter is deprecated Feng Tang
2025-08-25 2:57 ` [PATCH v2 4/4] panic: Clean up message about deprecated 'panic_print' parameter Feng Tang
2025-08-26 0:38 ` [PATCH v2 0/4] follow up patches for panic_print's generalization Andrew Morton
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=20250825025701.81921-2-feng.tang@linux.alibaba.com \
--to=feng.tang@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=john.ogness@linutronix.de \
--cc=lance.yang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=safinaskar@zohomail.com \
/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
all inboxes | Powered by JetHome®