From: Avi Weiss <thnkslprpt@gmail.com>
To: tglx@kernel.org
Cc: radu@rendec.net, linux-kernel@vger.kernel.org,
Avi Weiss <thnkslprpt@gmail.com>
Subject: [PATCH] genirq/core: Fall back to a static default affinity mask
Date: Sat, 31 Oct 2026 15:38:51 +0200 [thread overview]
Message-ID: <20261031133851.181601-1-thnkslprpt@gmail.com> (raw)
With CONFIG_CPUMASK_OFFSTACK=y, init_irq_default_affinity() does not
check whether zalloc_cpumask_var() succeeds. If the GFP_NOWAIT allocation
fails, cpumask_empty() dereferences a NULL mask during early boot.
Use a private static cpumask when allocation fails, keeping the default
IRQ affinity mask available and writable.
In a QEMU guest, a test-only allocation failure triggered the boot fault
without this change. The patched kernel booted with the same injected
failure and allowed the default affinity mask to be read and written.
Normal and irqaffinity=0 boots also passed.
Fixes: d036e67b40f5 ("cpumask: convert kernel/irq")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
kernel/irq/irqdesc.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 3a818f07a101..1ea020425381 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -25,6 +25,9 @@
static struct lock_class_key irq_desc_lock_class;
#if defined(CONFIG_SMP)
+#ifdef CONFIG_CPUMASK_OFFSTACK
+static cpumask_t irq_default_affinity_fallback;
+#endif
static int __init irq_affinity_setup(char *str)
{
alloc_bootmem_cpumask_var(&irq_default_affinity);
@@ -40,8 +43,12 @@ __setup("irqaffinity=", irq_affinity_setup);
static void __init init_irq_default_affinity(void)
{
- if (!cpumask_available(irq_default_affinity))
- zalloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT);
+ if (!cpumask_available(irq_default_affinity) &&
+ !zalloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT)) {
+#ifdef CONFIG_CPUMASK_OFFSTACK
+ irq_default_affinity = &irq_default_affinity_fallback;
+#endif
+ }
if (cpumask_empty(irq_default_affinity))
cpumask_setall(irq_default_affinity);
}
reply other threads:[~2026-10-31 13:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261031133851.181601-1-thnkslprpt@gmail.com \
--to=thnkslprpt@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=radu@rendec.net \
--cc=tglx@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®