From: David Engraf <david.engraf@sysgo.com>
To: tony.lindgren@linux.intel.com, pmladek@suse.com,
rostedt@goodmis.org, john.ogness@linutronix.de,
senozhatsky@chromium.org
Cc: linux-kernel@vger.kernel.org, David Engraf <david.engraf@sysgo.com>
Subject: [PATCH v3] printk: Remove console options before decoding the name
Date: Thu, 24 Sep 2026 10:00:57 +0300 [thread overview]
Message-ID: <20260924070153.250783-2-david.engraf@sysgo.com> (raw)
In-Reply-To: <582e545e-52b3-4adf-9c93-446ad0fecc93@sysgo.com>
This fixes a regression when a console option includes ':'. Commit
7640f1a44eba ("printk: Add match_devname_and_update_preferred_console()")
introduced console=DEVNAME:0.0 hardware style addressing by looking for a
colon. If the colon is part of an option the name is handled as devname
instead of ttyname.
Fix by handling the options first which will add a NULL terminator to the
string and refactor idx handling to clean up the code (thanks to Petr
Mladek).
Signed-off-by: David Engraf <david.engraf@sysgo.com>
---
kernel/printk/printk.c | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 6d3d18a50da74..2cbb84effb619 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2646,24 +2646,25 @@ static int __init console_setup(char *str)
if (_braille_console_setup(&str, &brl_options))
return 1;
+ /*
+ * Decode str into name, index and options. Start with options, since
+ * it might also contain a ':' used for DEVNAME.
+ */
+ options = strchr(str, ',');
+ if (options)
+ *(options++) = 0;
+
/* For a DEVNAME:0.0 style console the character device is unknown early */
if (strchr(str, ':'))
devname = buf;
else
ttyname = buf;
- /*
- * Decode str into name, index, options.
- */
if (ttyname && isdigit(str[0]))
scnprintf(buf, sizeof(buf), "ttyS%s", str);
else
strscpy(buf, str);
- options = strchr(str, ',');
- if (options)
- *(options++) = 0;
-
#ifdef __sparc__
if (!strcmp(str, "ttya"))
strscpy(buf, "ttyS0");
@@ -2671,17 +2672,18 @@ static int __init console_setup(char *str)
strscpy(buf, "ttyS1");
#endif
- for (s = buf; *s; s++)
- if ((ttyname && isdigit(*s)) || *s == ',')
- break;
-
- /* @idx will get defined when devname matches. */
- if (devname)
- idx = -1;
- else
+ if (ttyname) {
+ /* Detect @idx in ttyname and remove it. */
+ for (s = ttyname; *s; s++) {
+ if (isdigit(*s))
+ break;
+ }
idx = simple_strtoul(s, NULL, 10);
-
- *s = 0;
+ *s = 0;
+ } else {
+ /* @idx will get defined when devname matches. */
+ idx = -1;
+ }
__add_preferred_console(ttyname, idx, devname, options, brl_options, true);
return 1;
--
2.53.0
next prev parent reply other threads:[~2026-09-24 7:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 5:32 [PATCH] " David Engraf
2026-09-16 5:48 ` Tony Lindgren
2026-09-16 5:51 ` David Engraf
2026-09-17 6:05 ` [PATCH v2] " David Engraf
2026-09-17 14:03 ` Tony Lindgren
2026-09-18 6:27 ` David Engraf
2026-09-21 5:17 ` Tony Lindgren
2026-09-21 6:18 ` David Engraf
2026-09-23 9:37 ` Petr Mladek
2026-09-23 10:19 ` Tony Lindgren
2026-09-23 12:06 ` Petr Mladek
2026-09-23 12:14 ` Tony Lindgren
2026-09-23 13:56 ` David Engraf
2026-09-24 7:00 ` David Engraf [this message]
2026-09-24 7:42 ` [PATCH v3] " Tony Lindgren
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=20260924070153.250783-2-david.engraf@sysgo.com \
--to=david.engraf@sysgo.com \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=tony.lindgren@linux.intel.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®