Re: [PATCH v5 06/16] printk: Check that index is not defined when a console is preferred via devname
From: John Ogness
Date: Tue Oct 27 2026 - 14:10:04 EST
On 2026-09-29, Petr Mladek <pmladek@xxxxxxxx> wrote:
> The current code makes sure that a valid index is defined when a console
> is preferred via a name.
>
> On the contrary, the index must not be defined when the console is
> defined via a devname. The index will be defined later when the device
> matches and gets registered.
>
> Enforce the 2nd rule. Make the checks symmetric in the code.
> Do not ignore the errors quietly.
>
> Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>
Reviewed-by: John Ogness <john.ogness@xxxxxxxxxxxxx>
Minor nit below.
> ---
> kernel/printk/printk.c | 23 +++++++++++++----------
> 1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 0199c918ef03..b8c348e305eb 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2559,7 +2559,7 @@ asmlinkage __visible void early_printk(const char *fmt, ...)
> * it updates some global variables which are used to make the right decisions
> * in register_console(). Finally, it enforces some rules:
> *
> - * 1. Either @name OR @devname are allowed. [*]
> + * 1. Either @name and valid @idx OR @devname and @idx=-1 are allowed.
> *
> * [*] A valid @name and @idx will get assigned for a devname later when
> * @devname matches during the device initialization, see
You drop the [*] from rule #1. I think this was unintentional,
considering you later add a [**] for rule #4.
John