From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DDA83D88E2 for ; Wed, 3 Jun 2026 15:29:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780500592; cv=none; b=RDjz1l7evTUD1P6W5YJTRiqlbzZZWcn/np4lEJgRDDEO+5EqBBTrGUSHhPpQ9nDJFa1bIdqX5skkRg60VQ4WQsTUE7mUj9w8J1wEjFg7WRmNrdPRQRTlqMvV6DQ5Mi7JsBVhJ6eHCmh9/MBVYiSEAmGywuTAZ16arHRRFScbH+Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780500592; c=relaxed/simple; bh=JK+SAeDpJGuGqlGRurrVioz3d7awJdH6w4uBs/jX8F8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BMP490vDhsSlCZONHxFW1UU/6GN3IvHjC7tNlJQTpfaOL7/FVXpeB5fPGPbNB531KgbG8fVmnH+lBAvWAApKwCVBxlZyRFl5SLOZkTvZiUD5/Ye4wlvpODpGwrcpw29LoLq/KFnkm8IGl/ozZhCuHb98r3sgZTA4TbySufCPHhc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Fyo3aNSb; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Fyo3aNSb" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-490b3637b90so18057585e9.3 for ; Wed, 03 Jun 2026 08:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780500589; x=1781105389; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=MJKeV4uDExOKci84wa3qbikTE3Gx4IDQy1JpqTmVB9w=; b=Fyo3aNSbxr6HV4TX9r5AfctuIkkphSrZi7QSNToNQvTVaG85wKqJONeMSUzfjzU38M iEggfr+v2nok7KgsRjrHgSowl2o6vJ+uWDL/CwUfuU36PvkN+at4AZs6/sIMEEIkogY+ eDK3fDg690/kQNeTfkV8MXA6Z/8a7V31vNURM7Xo8GkdKnYYB/QbxzxJVxwCizcqTtkh vWH9N6F0qIzR6nb/H0k7yM79rsOUqyPShbMwHFEiIlOUrox+xko/JrRZ5hpMwW8EKwAN giF5LPtzNtGnA8PXk6Az/PZLUzBAKQ6w8BfINqwoDdwlyVcmRqOeuf21ftY4XgMRZNiJ NjvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780500589; x=1781105389; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MJKeV4uDExOKci84wa3qbikTE3Gx4IDQy1JpqTmVB9w=; b=iwzRoXJr0YpxUCbEgN7D75yUXNHc6wl0AQDmOR2nMFIF4FKPlnYIuW6Yuwj4UVIViq XJutdyquyWIRJq4t492XiikXGS+ak+5y2RoHYela1b0LYpoxf2PimgblWCa7q4ImSv9N dMANGtCUkU4ejOvdaD4/qxZnDZfXOGIvmqVV9sw+129ShRp4+X3BZTVbLrrVI6nO8GNt EjzwLB+VQ1t5ntCeFI1QjP2nRSCTiVTlI6zSznqXQx0+mtVhEcbvSxmq/MSJNC4v1pTV w8J5sgkgRO55b0CLOYZiCK8U00hzCavIHm0splFwxFcR3KKS67jaPEiJn770wCNBhZCY dsJg== X-Forwarded-Encrypted: i=1; AFNElJ9wzrSEVc1V5TOCK9buAIDTBQwL8FIFRvQ0VjSAIzIuD7eK8sNl8LFOrcvpa+hGbbr1V4DeBtwxB8jR0XQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyRarAEBA+9hHRCM51Z677WwneHfQPB2LCP/Qh/8M5YjxrTJkYN Csol/HYpO7wAZzjMpwuC4HilL8IR8UOFmG8D0VTNw09Tg0PA+lkSRnotLW/ymXlO0qo= X-Gm-Gg: Acq92OHgN9iyxWVfQpDsOS8V4gAmmL218e85IBX10bBJeGhurnUrGMYT/yCtNEy5kqu zqW9heRtTkI7ROddHCIc+cp9ddbzE/NCWea45vb3pAjtvF61obCdogBEkGafKZIUgdupKHLCC0Z TG/ajPqolSCIX/ZEBdfqPqOwkxtoZcOX/Rhza7BeYry4fLiNHoR83qV6ifnIqxXos7dEkxfFslC uDGlSNEIdQwonEZyxnUHYocwp64wsVckKRVBLfbj5y7xbX/p669x1gKfs5GJOmBt3D6Sdd3QHlb qOW+onPYaCvfJS3A7yupA8ksUy2h2JcFQcjFL4B1rqCWfoxJwCoYk+oZMxSytxiqNt2CCVpTq54 LmI0VkfAH5woIeia3611g4jy+TYdFQ1p9vuUjDIyalmk7USLpVkso/XRGy5u1Sg/gbDEx7Esd+1 mOu55Uswh+qedNhx0GLOgbTEDPyFfUgnwU448IwlJtfrTYSgg= X-Received: by 2002:a05:600c:a11:b0:490:9d1b:f086 with SMTP id 5b1f17b1804b1-490b5eb8333mr62460685e9.14.1780500589392; Wed, 03 Jun 2026 08:29:49 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2e4b18sm6278000f8f.10.2026.06.03.08.29.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 08:29:48 -0700 (PDT) Date: Wed, 3 Jun 2026 17:29:46 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 10/11] printk: Try enable preferred consoles only when there are any Message-ID: References: <20260602085312.228251-1-pmladek@suse.com> <20260602085312.228251-11-pmladek@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260602085312.228251-11-pmladek@suse.com> On Tue 2026-06-02 10:53:11, Petr Mladek wrote: > try_enable_preferred_console() used to be always called because it > had several hidden effects, namely: > > - enabled Braille consoles which were ignored by "preferred_dev_console" > because they were not associated with /dev/console. > > - returned success when a console was pre-enabled using CON_ENABLED > flag. > > - returned success when a console was enabled by default because > try_enable_default_console() did not return success. > > The first two hidden effects were removed in previous patches. The 2nd fix > actually helps even the 3rd case. try_enable_default_console() sets > CON_ENABLED flag on success and is later handled as pre-enabled. > > Prevent any future hidden effects and call try_enable_preferred_console() > only when some console is preferred. > > No behavior change. > > Signed-off-by: Petr Mladek > --- > kernel/printk/printk.c | 46 +++++++++++++++++++++--------------------- > 1 file changed, 23 insertions(+), 23 deletions(-) > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index a4eaf157cece..d62901a13bf7 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -4099,35 +4099,35 @@ static int try_enable_console(struct console *newcon) > return err; > } > > - /* > - * See if we want to enable this console driver by default. > - * > - * Nope when a console is preferred by the command line, device > - * tree, or SPCR. > - * > - * The first real console with tty binding (driver) wins. More > - * consoles might get enabled before the right one is found. > - * > - * Note that a console with tty binding will have CON_CONSDEV > - * flag set and will be first in the list. > - */ > - if (preferred_dev_console < 0) { > + if (preferred_dev_console >= 0) { > + /* See if this console matches one we selected on the command line */ > + err = try_enable_preferred_console(newcon, true); > + if (err != -ENOENT) > + return err; > + > + /* If not, try to match against the platform default(s) */ > + err = try_enable_preferred_console(newcon, false); > + if (err != -ENOENT) > + return err; > + } else { > + /* > + * See if we want to enable this console driver by default. > + * > + * Nope when a console is preferred by the command line, device > + * tree, or SPCR. > + * > + * The first real console with tty binding (driver) wins. More > + * consoles might get enabled before the right one is found. > + * > + * Note that a console with tty binding will have CON_CONSDEV > + * flag set and will be first in the list. > + */ > if (hlist_empty(&console_list) || !console_first()->device || > console_first()->flags & CON_BOOT) { > try_enable_default_console(newcon); > } This will require initializing err variable at the beginnit to prevent returning a random value. I am going to fix it in v4. Note that I am working on v4 because we want to fix handling pre-enabled consoles in a first patch. It will prevent an out-of-bound access, see https://lore.kernel.org/all/7sq4tr2nmlz32tvkf6vpsghv6exvqfghsrlvywjcqihzsqqbf7@bspclmti5xg4/ > } > > - /* See if this console matches one we selected on the command line */ > - err = try_enable_preferred_console(newcon, true); > - if (err != -ENOENT) > - return err; > - > - /* If not, try to match against the platform default(s) */ > - err = try_enable_preferred_console(newcon, false); > - if (err != -ENOENT) > - return err; > - > /* > * Some consoles, such as pstore and netconsole, can be enabled even > * without matching. Accept them at this stage when they had a chance Best Regards, Petr PS: You might want to ignore v3. I am going to send v4 tomorrow after I double check the reshufling of the patches.