From: tip-bot for Yinghai Lu <yinghai@kernel.org>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
yinghai@kernel.org, tglx@linutronix.de
Subject: [tip:irq/core] genirq: Use IRQ_BITMAP_BITS as search size in irq_alloc_descs()
Date: Mon, 21 Feb 2011 20:22:47 GMT [thread overview]
Message-ID: <tip-ed4dea6e0e33a3e58d8b77b775a8f0e433e7a005@git.kernel.org> (raw)
In-Reply-To: <4D6014F9.8040605@kernel.org>
Commit-ID: ed4dea6e0e33a3e58d8b77b775a8f0e433e7a005
Gitweb: http://git.kernel.org/tip/ed4dea6e0e33a3e58d8b77b775a8f0e433e7a005
Author: Yinghai Lu <yinghai@kernel.org>
AuthorDate: Sat, 19 Feb 2011 11:07:37 -0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 21 Feb 2011 21:20:00 +0100
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>
---
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 394ab6a..dbccc79 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)
return NULL;
}
-static int irq_expand_nr_irqs(unsigned int cnt)
+static int irq_expand_nr_irqs(unsigned int nr)
{
- if (nr_irqs + cnt > IRQ_BITMAP_BITS)
+ if (nr > IRQ_BITMAP_BITS)
return -ENOMEM;
- nr_irqs += cnt;
+ nr_irqs = nr;
return 0;
}
@@ -298,7 +298,7 @@ static inline int alloc_descs(unsigned int start, unsigned int cnt, int node)
return start;
}
-static int irq_expand_nr_irqs(unsigned int cnt)
+static int irq_expand_nr_irqs(unsigned int nr)
{
return -ENOMEM;
}
@@ -346,13 +346,14 @@ irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node)
mutex_lock(&sparse_irq_lock);
- start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0);
+ start = bitmap_find_next_zero_area(allocated_irqs, IRQ_BITMAP_BITS,
+ from, cnt, 0);
ret = -EEXIST;
if (irq >=0 && start != irq)
goto err;
- if (start >= nr_irqs) {
- ret = irq_expand_nr_irqs(cnt);
+ if (start + cnt > nr_irqs) {
+ ret = irq_expand_nr_irqs(start + cnt);
if (ret)
goto err;
}
prev parent reply other threads:[~2011-02-21 20:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <tip-e7bcecb7b1d29b9ad5af939149a945658620ca8f@git.kernel.org>
2011-02-19 19:07 ` [tip:irq/core] genirq: Make nr_irqs runtime expandable Yinghai Lu
2011-02-21 13:37 ` Thomas Gleixner
2011-02-21 13:43 ` Thomas Gleixner
2011-02-21 15:56 ` Lars-Peter Clausen
2011-02-21 17:57 ` Yinghai Lu
2011-02-21 19:17 ` Thomas Gleixner
2011-02-21 20:22 ` tip-bot for Yinghai Lu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-ed4dea6e0e33a3e58d8b77b775a8f0e433e7a005@git.kernel.org \
--to=yinghai@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome