From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 3AAFF33FE1A for ; Thu, 19 Feb 2026 15:16:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771514189; cv=none; b=EMiwOyQ+Ht4+iYQ1GCk7IWbaCpCeNMFNU2n6Q+z+MgUWZ8+OppZFjNu3ILqZXIVfVwqNRYdlDN2gmYYu+x3kWGMdTAvYumoiwKuTwBH0k3wS6jjg6MMk0WX4COWhhAYgXAsxTzqLKadVep6RLiYUYVUJ4BpdTZ1rezbUpGKvzP4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771514189; c=relaxed/simple; bh=XCPlpmoC4Ooq3VI3dQ5EdStPuGiOdM+MmJxvfxYUn1k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dn/GWCPthXiqfMEp4UJ7z/Z2Yx3EeeTNrDnvgiLJFyauntgJIRPVtibtdQXy5ZikZuGP45S+Vt83HaTAPTM68W/t3zZeCGyRXSx38/z6A6J6wNAhEWwHkjuHNjPRx8k64I7E5v18faNk1ImiTxevJRYGNFHiDsN5YyA4LYMmV8c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chrisdown.name; spf=pass smtp.mailfrom=chrisdown.name; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.b=CohnAcPp; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.b="CohnAcPp" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-823075fed75so544724b3a.1 for ; Thu, 19 Feb 2026 07:16:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1771514187; x=1772118987; darn=vger.kernel.org; h=user-agent: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=Au29mM04UNKKzthMW1Tyf66I5YWhSY52Sz7XAz1bwDE=; b=CohnAcPpkZrnTUGgyeKGUYgNAJTNKR+sEAzUY2prvPh7HZR9L9M0tXbbq5iyy/idvL 0VYbF/wBXN+gdnm6gPMbxq4ANm6oyXdnYZisZr2SzcJgG/jpdfwcJuWvEbCEqRyNdOse zdbEtqV3FZz2pCZ4AUPd6K9IB7OORxt8YufPo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771514187; x=1772118987; h=user-agent: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=Au29mM04UNKKzthMW1Tyf66I5YWhSY52Sz7XAz1bwDE=; b=b00uG0FkVq6bLIh8C3IRow6TMy9t/dywmUDVrcVh1B6Oy3xHOAbA2c4rEITzu37jhs KOPQj+0C1C1aZr+jPH2EURyffIkuZnwYrY3mZgOM8SmPx7WThmtUTFHTRbfssbBs3DIa DRlqs/PvAyxqJQxZqtVJJrC4QJSud7/mgzquBMg1mXkMMY3x8jyWdpztM68MvMFlD5S+ pQBdlSXIjHFj7R3AyLPjm+OuGGF7AxPyH/wgAPPZo01HeQL33o/Jo+wPbJDCXkIBK9xd +v0FajcqeFXSRAXaNfL+JcWAAhdGOnWmzi7YTqAZzSMY8hTAD8oZU8rYwhVo6U2CKhBy HmIw== X-Forwarded-Encrypted: i=1; AJvYcCWJwKU/CRW4Z5JprAbOOLCnUu2HDt1BVnJ3ZhZLusMIQDVr+OZzasRZBC/Ol6d0cUWefFg4BAa/soaaol4=@vger.kernel.org X-Gm-Message-State: AOJu0YwP6/g3q+Ti6ayk0zteDF80Fj2FA+w1v/+I/CWr4hAa/VpvbjvQ yoIQJuFqKMzryu2WNOComvYKoiLvrdUE1dIhEWItszR/qa4/gGu3fdR53mZRMYh2frs= X-Gm-Gg: AZuq6aJEm9Yely64EAUIYexKQxjeeBozbZWRc0z09l4XOY/KLKNI+OVPmIJfI/tsGqc xX6kIBXXrIMIy0GA+84wH17vaQV6zbSCUffewESSF+AGZ5F1C8+k+DVGqQLFG3gmBPLlw1ykw42 HGJ9tjzONZnMnMJVbWIPNWW3RaOuPei4jm4Hmq82j+Dhm9V6qYcOWDjt+Qrme8Fvf42grv+EdVU yxBZwJLl/JDGPqw0z/LIzUqIAVufVlzijGtIPMOkN0n3Qx3e9C0iHi1YYBIWbZeUPPQYb8g8/87 HtmG8+EgQE/KpgiVXnaeIX3Yparnvmw9f4OLTfeIlbqrTgHgTnkgI50M/IVCTVYNYPeQtzbAwPs WQSHBNbEyPs0M71Y+/qXirHEFRIhKdjOOFI0x45fm3NpgQXrTQ21+zd6IJkebyWVsg+vdAgS5bY jKeQE206tE1sA0+sn59rm5 X-Received: by 2002:a05:6a21:1798:b0:366:14b0:4b19 with SMTP id adf61e73a8af0-39517e1ffeemr2292912637.36.1771514187504; Thu, 19 Feb 2026 07:16:27 -0800 (PST) Received: from localhost ([175.139.248.66]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c6e53342ce4sm18558897a12.34.2026.02.19.07.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 07:16:26 -0800 (PST) Date: Thu, 19 Feb 2026 23:16:24 +0800 From: Chris Down To: Petr Mladek Cc: John Ogness , Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , linux-kernel@vger.kernel.org Subject: Re: [PATCH 8/8] printk: Try enable preferred consoles only when there are any Message-ID: References: <20260206165002.496724-1-pmladek@suse.com> <20260206165002.496724-9-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; format=flowed Content-Disposition: inline In-Reply-To: <20260206165002.496724-9-pmladek@suse.com> User-Agent: Mutt/2.2.15 (2b349c5e) (2025-10-02) Petr Mladek writes: >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. Remove >the last one so that try_enable_preferred_console() can be called only >when any non-Braille console is preferred. There is a fourth hidden effect that was also removed, unconditionally initialising err :-) Unfortunately removing that causes an uninitialised read. >@@ -4156,17 +4161,15 @@ void register_console(struct console *newcon) > if (preferred_dev_console < 0) { > if (hlist_empty(&console_list) || !console_first()->device || > console_first()->flags & CON_BOOT) { >- try_enable_default_console(newcon); >+ err = try_enable_default_console(newcon); > } >+ } else { >+ err = try_enable_preferred_console(newcon, true); >+ >+ if (err == -ENOENT) >+ err = try_enable_preferred_console(newcon, false); > } When preferred_dev_console < 0 and the inner condition is false, nothing will initialise err. > >- /* See if this console matches one we selected on the command line */ >- err = try_enable_preferred_console(newcon, true); >- >- /* If not, try to match against the platform default(s) */ >- if (err == -ENOENT) >- err = try_enable_preferred_console(newcon, false); You can see previously it was initialised without conditions here. Later we read err with `if (err == -ENOENT)`, so it's possible to do an uninitialised read. Doing `int err = -ENOENT` at declaration should fix it by the look of it.