printk: Check valid console index for preferred console
authorTony Lindgren <tony@atomide.com>
Thu, 12 Oct 2023 06:42:56 +0000 (09:42 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Oct 2023 08:18:59 +0000 (10:18 +0200)
commit545a4f89cad5bd349522d17558b3a4208648e20e
treed4b4055f77c23696ead18417a1671a6b8d932251
parenta07b50d80ab621f4f18d429068a43cffec26691f
printk: Check valid console index for preferred console

Let's check for valid console index values for preferred console to avoid
bogus console index numbers from kernel command line.

Let's also return an error for negative index numbers for the preferred
console. Unlike for device drivers, a negative index is not valid for the
preferred console.

Let's also constify idx while at it.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20231012064300.50221-1-tony@atomide.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/console.h
kernel/printk/printk.c