sparseirq: fix desc->lock init

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Wednesday, December 31, 2008 - 5:59 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=793f7b...
Commit:     793f7b12a0c95e7bfec1badf9628043fb78fd440
Parent:     8b07cd44511f3aa78dd912cca6493275a6787dc5
Author:     Ingo Molnar <mingo@elte.hu>
AuthorDate: Fri Dec 26 19:02:20 2008 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Sat Dec 27 09:29:22 2008 +0100

    sparseirq: fix desc->lock init
    
    Impact: cleanup
    
    init_one_irq_desc() does not initialize the desc->lock properly -
    you cannot init a lock by memcpying some other lock on it.
    
    This happens to work right now (because irq_desc_init is never in use),
    but it's a dangerous construct nevertheless, so fix it.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/irq/handle.c       |    2 ++
 kernel/irq/numa_migrate.c |    1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 06b05a4..893da67 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -93,6 +93,8 @@ void __attribute__((weak)) arch_init_chip_data(struct irq_desc *desc, int cpu)
 static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu)
 {
 	memcpy(desc, &irq_desc_init, sizeof(struct irq_desc));
+
+	spin_lock_init(&desc->lock);
 	desc->irq = irq;
 #ifdef CONFIG_SMP
 	desc->cpu = cpu;
diff --git a/kernel/irq/numa_migrate.c b/kernel/irq/numa_migrate.c
index a565ce3..ecf765c 100644
--- a/kernel/irq/numa_migrate.c
+++ b/kernel/irq/numa_migrate.c
@@ -42,6 +42,7 @@ static void init_copy_one_irq_desc(int irq, struct irq_desc *old_desc,
 		 struct irq_desc *desc, int cpu)
 {
 	memcpy(desc, old_desc, sizeof(struct irq_desc));
+	spin_lock_init(&desc->lock);
 	desc->cpu = cpu;
 	lockdep_set_class(&desc->lock, &irq_desc_lock_class);
 	init_copy_kstat_irqs(old_desc, desc, cpu, nr_cpu_ids);
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
sparseirq: fix desc->lock init, Linux Kernel Mailing ..., (Wed Dec 31, 5:59 pm)