Skip to content

Commit

Permalink
sparseirq: make for_each_irq_desc() more robust
Browse files Browse the repository at this point in the history
Raja reported for_each_irq_desc() has possibility unsafeness:

if anyone write folliwing code, for_each_irq_desc() doesn't work
as intended:

(right now this code does not exist at all)

 if (safe)
   for_each_irq_desc(irq, desc) {
      ...
   }
 else
   panic();

Reported-by: Raja R Harinath <harinath@hurrynot.org>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
KOSAKI Motohiro authored and Ingo Molnar committed Jan 7, 2009
1 parent ede6f5a commit 01d0782
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/linux/irqnr.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ extern struct irq_desc *irq_to_desc(unsigned int irq);
# define for_each_irq_desc(irq, desc) \
for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \
irq++, desc = irq_to_desc(irq)) \
if (desc)
if (!desc) \
; \
else


# define for_each_irq_desc_reverse(irq, desc) \
for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \
irq--, desc = irq_to_desc(irq)) \
if (desc)
if (!desc) \
; \
else

#endif /* CONFIG_GENERIC_HARDIRQS */

Expand Down

0 comments on commit 01d0782

Please sign in to comment.