lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 12 Nov 2023 02:00:36 +0900
From:   Paran Lee <p4ranlee@...il.com>
To:     Thomas Gleixner <tglx@...utronix.de>, Marc Zyngier <maz@...nel.org>
Cc:     linux-kernel@...r.kernel.org, shjy180909@...il.com,
        austindh.kim@...il.com, Paran Lee <p4ranlee@...il.com>
Subject: [PATCH] irqdesc: Fail check on early_irq_init allocation.

When doing start_kernel(),
On early_irq_init(), alloc_desc() or alloc_percpu()
may be fails. So, Explicit fail check needed on dynamic allocation.

Signed-off-by: Paran Lee <p4ranlee@...il.com>
---
 kernel/irq/irqdesc.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 27ca1c866f29..bdc35823e4c4 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -565,6 +565,7 @@ int __init early_irq_init(void)
 
 	for (i = 0; i < initcnt; i++) {
 		desc = alloc_desc(i, node, 0, NULL, NULL);
+		BUG_ON(!desc);
 		irq_insert_desc(i, desc);
 	}
 	return arch_early_irq_init();
@@ -582,18 +583,16 @@ struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
 
 int __init early_irq_init(void)
 {
-	int count, i, node = first_online_node;
-	struct irq_desc *desc;
+	int count = ARRAY_SIZE(irq_desc), i, node = first_online_node;
+	struct irq_desc *desc = irq_desc;
 
 	init_irq_default_affinity();
 
 	printk(KERN_INFO "NR_IRQS: %d\n", NR_IRQS);
 
-	desc = irq_desc;
-	count = ARRAY_SIZE(irq_desc);
-
 	for (i = 0; i < count; i++) {
 		desc[i].kstat_irqs = alloc_percpu(unsigned int);
+		BUG_ON(!desc[i].kstat_irqs);
 		alloc_masks(&desc[i], node);
 		raw_spin_lock_init(&desc[i].lock);
 		lockdep_set_class(&desc[i].lock, &irq_desc_lock_class);
-- 
2.25.1

Powered by blists - more mailing lists