lkml.org 
[lkml]   [2008]   [Dec]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH -tip] irq: check chip->ack before calling (WAS: irq: remove unneeded desc->chip->ack check)
Ingo Molnar said the following on 2008-12-26 21:27:
> * Wang Chen <wangchen@cn.fujitsu.com> wrote:
>
>> desc->chip->ack is initialized to ack_bad().
>> It will not be NULL.
>
> hm, that is only true of no_irq_chip() - is it true of all irq_chip
> definitions on all architectures?
>

No, some arch's irq_chip doesn't have ack routine.
So I was wrong.
But this enlighten another thought that generic irq layer doesn't know
whether irq_chip has ack routine on some architectures.
Upon that, before calling chip->ack, should check it's not NULL.

Impact: fix theoretic NULL dereference

Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
---
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index f63c706..9a7fbb8 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -290,7 +290,8 @@ static inline void mask_ack_irq(struct irq_desc *desc, int irq)
desc->chip->mask_ack(irq);
else {
desc->chip->mask(irq);
- desc->chip->ack(irq);
+ if (desc->chip->ack)
+ desc->chip->ack(irq);
}
}

@@ -475,7 +476,8 @@ handle_edge_irq(unsigned int irq, struct irq_desc *desc)
kstat_incr_irqs_this_cpu(irq, desc);

/* Start handling the irq */
- desc->chip->ack(irq);
+ if (desc->chip->ack)
+ desc->chip->ack(irq);
desc = irq_remap_to_desc(irq, desc);

/* Mark the IRQ currently in progress.*/

\
 
 \ /
  Last update: 2008-12-29 06:37    [W:0.595 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site