[PATCH v8 16/21] printk: Constrain hardware-addressed console checks to name position

Chris Down posted 21 patches 4 days, 1 hour ago
Only 20 patches received!
[PATCH v8 16/21] printk: Constrain hardware-addressed console checks to name position
Posted by Chris Down 4 days, 1 hour ago
Commit 7640f1a44eba ("printk: Add
match_devname_and_update_preferred_console()") adds support for
DEVNAME:n:n style console= registration. It determines whether or not
this is a hardware-addressed console by looking at whether the console=
string has a colon in it. However, this interferes with loglevel:n and
potentially other future named options, which also make use of the
character.

In order to avoid this, only search positions before options.

Reviewed-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Tony Lindgren <tony.lindgren@linux.intel.com>
Signed-off-by: Chris Down <chris@chrisdown.name>
---
 kernel/printk/printk.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 605e0811cfc6..32ea9b69f515 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2813,6 +2813,7 @@ static int __init console_setup(char *str)
 	char *devname = NULL;
 	char *options;
 	char *s;
+	char *first_delim;
 	int idx;
 
 	/*
@@ -2828,8 +2829,13 @@ static int __init console_setup(char *str)
 	if (_braille_console_setup(&str, &brl_options))
 		return 1;
 
-	/* For a DEVNAME:0.0 style console the character device is unknown early */
-	if (strchr(str, ':'))
+	/*
+	 * For a DEVNAME:0.0 style console the character device is unknown
+	 * early. We must restrict this to before any comma to avoid interfering
+	 * with named options, like "loglevel".
+	 */
+	first_delim = strpbrk(str, ":,");
+	if (first_delim && *first_delim == ':')
 		devname = buf;
 	else
 		ttyname = buf;
-- 
2.51.2