[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220420140521.45361-2-kernelfans@gmail.com>
Date: Wed, 20 Apr 2022 22:05:13 +0800
From: Pingfan Liu <kernelfans@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Pingfan Liu <kernelfans@...il.com>,
Thomas Gleixner <tglx@...utronix.de>
Subject: [PATCH 1/9] irq/irqdesc: put the lock at the exact place in irq_sysfs_init()
sparse_irq_lock is used to protect irq_desc, and furthermore
irq_sysfs_init() is called only once, so put irq_lock_sparse() at the
exact place, where the race condition may start.
Signed-off-by: Pingfan Liu <kernelfans@...il.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
To: linux-kernel@...r.kernel.org
---
kernel/irq/irqdesc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 939d21cd55c3..8d0982233277 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -312,15 +312,14 @@ static int __init irq_sysfs_init(void)
struct irq_desc *desc;
int irq;
- /* Prevent concurrent irq alloc/free */
- irq_lock_sparse();
-
irq_kobj_base = kobject_create_and_add("irq", kernel_kobj);
if (!irq_kobj_base) {
- irq_unlock_sparse();
return -ENOMEM;
}
+ /* Prevent concurrent irq alloc/free */
+ irq_lock_sparse();
+
/* Add the already allocated interrupts */
for_each_irq_desc(irq, desc)
irq_sysfs_add(irq, desc);
--
2.31.1
Powered by blists - more mailing lists