From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 6BC571A9F9F for ; Thu, 4 Jun 2026 10:17:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780568232; cv=none; b=oFYjTUI6UlDA4AxvneZO58DlupUq0Kz2KXesHa+F9ZqHhwSUiN+zaQnUseCosYQY7F8AHxrIwyznvVCcxmfqyiKCW+/+EQYzbT7PVDRGsR5gKlMv3sIfVeuI7K7/Bc9eauqaYgZfRNixa04zaTVUnUzl3fYWDVK2eSU29qF0nCU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780568232; c=relaxed/simple; bh=OhlPCZKHpFc/1MXB5axzKBR3R03Mebv+nxjSEXr9JMY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y6wVXbcK2j9Ybo+g5Vj5B81oqs1/sVf1D9etbGElmKU4t3euxTAv1Tfd1rAAP3jq93is02/VQXxP5CmNZv8bOuQ9hqk82p+r+5+7P5HWM/7jA6f4Y1B7b/zLwZ6vzo+PGrxiCEAaNLl/3vqW2Bz2WHxLTfVkxvF8ff6CvIBgBSI= 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=Rwg2qb1w; arc=none smtp.client-ip=209.85.221.49 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="Rwg2qb1w" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-45eedc94d37so258999f8f.3 for ; Thu, 04 Jun 2026 03:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780568230; x=1781173030; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1Axeu4fMcBEJteme8OlMPdFFTSrwMBXiECzKN1qnIMQ=; b=Rwg2qb1wDgFfm7bxyIFJL6mdUuUC7QK90Xu2/TkXTCYt1y/PnqV7k+7SaZoroNYf5Y Si2pKrGTK27KCNHDfqnshTSHXlHZZOr0XAtHFNmDk7PCXSvMlHKIFfnUyBhOJls74zR1 Z0+/0hPcT5pRoAGW8zvKWL8VPnsMPoekNegToGyVkCMSIh6Nl6Yjwv6BKLG//M+08Q9b 90UvX/2qkLi8oKXyflJdV5WIfoL/kGwCBl1W6jTjbFjG/+0MmAc5JcorJ6APW64yIqKZ lfi0ptvRz3Y0L6IR717BgIxlGin/SpintVsw2Zd15RUWrSTuHObG2NEWNIoCqWIOEb/2 rK8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780568230; x=1781173030; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=1Axeu4fMcBEJteme8OlMPdFFTSrwMBXiECzKN1qnIMQ=; b=Bgd2pMTHcRWaqKj1yQRocuJNAmD/k7VziU1Pwbn3Rjr1xytJs3ylifFS+5epCY4L4G K8yvdlNKlG0x1qwRce+7FPc0DVIGbsAsYazyBzhuEGBA31ekBY46BBVUMoyMA4cDPEme hMM2eYu3N2EsU9nCvQJueH7z/gsbxottNJMRuEYNa+MNCkemcOWZe0Eevp50jPLballB Unwai3eB4bgQEgAHPcIUaF5tOA8kqXY3nHLwA5Mn1Im8nWIg8+sSdUhA2wE7TJTL/qlS ao4YsFuj67uH3cGumgjUwoj4MBGLR6NQEn9RO7zOcqsNC0MAMCAeUNkSmANiWSZ/D0vP Uwgw== X-Forwarded-Encrypted: i=1; AFNElJ/xWtemiioHCWhJUBf/VsFhxqrdTudP9EFWYLNBCQUIVDzhV8xyqdZtm9SYdOVDqFzt5mGRbtNsNVxjSSQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6k8nTVBvi3o2kY2egAtcToZ2xLKOXq4c+IreOIOz9lizaMu18 GwqPCvzRKsWFOT05ZXgvvZepBM4KvjPD69cjd7A3gTldLWYVgjTT6TEmjmc+Is6/CsrQYNKAQQC B+KOb X-Gm-Gg: Acq92OEioSONm/LNytpWaHNfE79gCg1UC9qAf0u/P36emi1E407q7N8Uocxa7ZadnSd jJF9N0Ja3+GVWD7DTPeLdsQVxiTj/EoNt4iuv38lUkvfWw3ijLNPQ4aiTwFP2++bzEyeVBlHlxI C2dHrLi7Ds2cop4oG7dytK7i9FM20f3byZi9iBFEzB6AXqxK50EAkgFx14uXAJGKrap7hZ0W75k XuctUyKa/eOqTty28ZnRj7NaALXLOoxMCb85t4LowLMdHBRB7qjKp5pRF9B9Lq9FCI9gYgxDx3i 5E5cDBIG/0MY+YTIl2h51qhrtXY9C6e2v7kEMIM6wQjUTVgHoLWVlpjh6Gx1eYYXNh1afT3Uylw bz3SYnmvHWCjFFnuJLLJbfVhjZVkbZpZTVZw0H3eRTNyNFjjrFPgUE3SQxCH9JBXjQJ/xXw6I4z jWivFuvbaEaX4niJLcfy0sezCeqicNjdrf5zvG8RjJKNbEk78= X-Received: by 2002:a5d:5702:0:b0:43d:775b:c9bd with SMTP id ffacd0b85a97d-460217a6ff6mr8303264f8f.10.1780568229625; Thu, 04 Jun 2026 03:17:09 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f35fd33sm16574514f8f.35.2026.06.04.03.17.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 03:17:08 -0700 (PDT) From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , Naveen Kumar Chaudhary , linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH v4 10/11] printk: Modify try_enable_default_console() to return error/success Date: Thu, 4 Jun 2026 12:14:57 +0200 Message-ID: <20260604101459.393162-11-pmladek@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260604101459.393162-1-pmladek@suse.com> References: <20260604101459.393162-1-pmladek@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Currently, try_enable_default_console() has a void return type, and its potential failures (specifically when console_call_setup() fails) are ignored by its caller, try_enable_console(). Modify try_enable_default_console() to return error/success, and update try_enable_console() to capture and propagate this error. With this change, try_enable_console() will no longer return success for a pre-enabled console if try_enable_default_console() failed (such as when newcon->setup() fails). While this might change existing behavior, it is the correct approach to ensure setup errors are not silently ignored or treated as successful registrations simply because the console was marked pre-enabled. Assisted-by: Gemini:gemini-3 # commit message Signed-off-by: Petr Mladek --- kernel/printk/printk.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index a4eaf157cece..b0df4a23252d 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -4060,18 +4060,23 @@ static int try_enable_braille_console(struct console *newcon) } /* Try to enable the console unconditionally */ -static void try_enable_default_console(struct console *newcon) +static int try_enable_default_console(struct console *newcon) { + int err; + if (newcon->index < 0) newcon->index = 0; - if (console_call_setup(newcon, NULL) != 0) - return; + err = console_call_setup(newcon, NULL); + if (err) + return err; newcon->flags |= CON_ENABLED; if (newcon->device) newcon->flags |= CON_CONSDEV; + + return 0; } #define console_first() \ @@ -4114,7 +4119,9 @@ static int try_enable_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); + if (err != -ENOENT) + return err; } } -- 2.54.0