diff options
author | Yinghai Lu <yinghai@kernel.org> | 2011-02-19 14:07:37 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2011-02-21 15:20:00 -0500 |
commit | ed4dea6e0e33a3e58d8b77b775a8f0e433e7a005 (patch) | |
tree | 99f3168f5307545e6107603431e877b5369f767f /kernel/irq | |
parent | a61d825808a0ce9935afebc225dcd602d5339e14 (diff) |
genirq: Use IRQ_BITMAP_BITS as search size in irq_alloc_descs()
The runtime expansion of nr_irqs does not take into account that
bitmap_find_next_zero_area() returns "start" + size in case the search
for an matching zero area fails. That results in a start value which
can be completely off and is not covered by the following
expand_nr_irqs() and possibly outside of the absolute limit. But we
use it without further checking.
Use IRQ_BITMAP_BITS as the limit for the bitmap search and expand
nr_irqs when the start bit is beyond nr_irqs. So start is always
pointing to the correct area in the bitmap. nr_irqs is just the limit
for irq enumerations, not the real limit for the irq space.
[ tglx: Let irq_expand_nr_irqs() take the new upper end so we do not
expand nr_irqs more than necessary. Made changelog readable ]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <4D6014F9.8040605@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/irq')
-rw-r--r-- | kernel/irq/irqdesc.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 394ab6a6c62c..dbccc799407f 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c | |||
@@ -207,11 +207,11 @@ struct irq_desc * __ref irq_to_desc_alloc_node(unsigned int irq, int node) | |||
207 | return NULL; | 207 | return NULL; |
208 | } | 208 | } |
209 | 209 | ||
210 | static int irq_expand_nr_irqs(unsigned int cnt) | 210 | static int irq_expand_nr_irqs(unsigned int nr) |
211 | { | 211 | { |
212 | if (nr_irqs + cnt > IRQ_BITMAP_BITS) | 212 | if (nr > IRQ_BITMAP_BITS) |
213 | return -ENOMEM; | 213 | return -ENOMEM; |
214 | nr_irqs += cnt; | 214 | nr_irqs = nr; |
215 | return 0; | 215 | return 0; |
216 | } | 216 | } |
217 | 217 | ||
@@ -298,7 +298,7 @@ static inline int alloc_descs(unsigned int start, unsigned int cnt, int node) | |||
298 | return start; | 298 | return start; |
299 | } | 299 | } |
300 | 300 | ||
301 | static int irq_expand_nr_irqs(unsigned int cnt) | 301 | static int irq_expand_nr_irqs(unsigned int nr) |
302 | { | 302 | { |
303 | return -ENOMEM; | 303 | return -ENOMEM; |
304 | } | 304 | } |
@@ -346,13 +346,14 @@ irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node) | |||
346 | 346 | ||
347 | mutex_lock(&sparse_irq_lock); | 347 | mutex_lock(&sparse_irq_lock); |
348 | 348 | ||
349 | start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0); | 349 | start = bitmap_find_next_zero_area(allocated_irqs, IRQ_BITMAP_BITS, |
350 | from, cnt, 0); | ||
350 | ret = -EEXIST; | 351 | ret = -EEXIST; |
351 | if (irq >=0 && start != irq) | 352 | if (irq >=0 && start != irq) |
352 | goto err; | 353 | goto err; |
353 | 354 | ||
354 | if (start >= nr_irqs) { | 355 | if (start + cnt > nr_irqs) { |
355 | ret = irq_expand_nr_irqs(cnt); | 356 | ret = irq_expand_nr_irqs(start + cnt); |
356 | if (ret) | 357 | if (ret) |
357 | goto err; | 358 | goto err; |
358 | } | 359 | } |