Skip to contentSkip to conversation

powerpc: fix logic error in fixup_irqs

PATCH Superseded Johannes Berg 1 participant 3 messages Jun 11, 2010 – Jun 16, 2010 1 message not in the archive PowerPC

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 powerpc: fix logic error in fixup_irqs

When SPARSE_IRQ is set, irq_to_desc() can return NULL. While the code here has a check for NULL, it's not really correct. Fix it by separating the check for it.

This fixes CPU hot unplug for me.

---
v2: cc Alastair, sorry

 arch/powerpc/kernel/irq.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/kernel/irq.c +4 -1
@@ -295,7 +295,10 @@ void fixup_irqs(const struct cpumask *ma
 
 	for_each_irq(irq) {
 		desc = irq_to_desc(irq);
-		if (desc && desc->status & IRQ_PER_CPU)
+		if (!desc)
+			continue;
+
+		if (desc->status & IRQ_PER_CPU)
 			continue;
 
 		cpumask_and(mask, desc->affinity, map);
#2 lore raw
Quoted 4 lines · Johannes Berg

When SPARSE_IRQ is set, irq_to_desc() can return NULL. While the code here has a check for NULL, it's not really correct. Fix it by separating the check for it.

Incidentally, there's another quirk in fixup_irqs():

...

        alloc_cpumask_var(&mask, GFP_KERNEL);
...
        local_irq_enable();
        mdelay(1);
        local_irq_disable();

Either it's called with IRQs disabled, in which case it shouldn't do GFP_KERNEL, or it's called with IRQs enabled, in which case it doesn't need the local_irq_enable(), no?

johannes

#3 lore raw

PATCH v3 1/1 powerpc: fix logic error in fixup_irqs

In reply to a message not in the archive

When SPARSE_IRQ is set, irq_to_desc() can return NULL. While the code here has a check for NULL, it's not really correct. Fix it by separating the check for it.

This fixes CPU hot unplug for me.

---
v2: cc Alastair, sorry
v3: indicate stable versions

 arch/powerpc/kernel/irq.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/kernel/irq.c +4 -1
@@ -295,7 +295,10 @@ void fixup_irqs(const struct cpumask *ma
 
 	for_each_irq(irq) {
 		desc = irq_to_desc(irq);
-		if (desc && desc->status & IRQ_PER_CPU)
+		if (!desc)
+			continue;
+
+		if (desc->status & IRQ_PER_CPU)
 			continue;
 
 		cpumask_and(mask, desc->affinity, map);