[PATCH] printk: Check valid console index for preferred console
From: Tony Lindgren
Date: Wed Oct 04 2023 - 04:55:07 EST
Let's check for valid console index values.
Signed-off-by: Tony Lindgren <tony@xxxxxxxxxxx>
---
kernel/printk/printk.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2410,6 +2410,10 @@ static int __add_preferred_console(char *name, int idx, char *options,
struct console_cmdline *c;
int i;
+ /* See struct console */
+ if (idx > SHRT_MAX)
+ return -EINVAL;
+
/*
* See if this tty is not yet registered, and
* if we have a slot free.
--
2.42.0