linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Mark Brown <broonie@opensource.wolfsonmicro.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
	broonie@opensource.wolfsonmicro.com, tglx@linutronix.de
Subject: [tip:irq/urgent] genirq: Ensure we locate the passed IRQ in irq_alloc_descs()
Date: Fri, 3 Jun 2011 12:59:08 GMT	[thread overview]
Message-ID: <tip-c5182b8867e189e14a8df5dbfcba1c73f286e061@git.kernel.org> (raw)
In-Reply-To: <1307037313-15733-1-git-send-email-broonie@opensource.wolfsonmicro.com>

Commit-ID:  c5182b8867e189e14a8df5dbfcba1c73f286e061
Gitweb:     http://git.kernel.org/tip/c5182b8867e189e14a8df5dbfcba1c73f286e061
Author:     Mark Brown <broonie@opensource.wolfsonmicro.com>
AuthorDate: Thu, 2 Jun 2011 18:55:13 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 3 Jun 2011 14:53:16 +0200

genirq: Ensure we locate the passed IRQ in irq_alloc_descs()

When irq_alloc_descs() is called with no base IRQ specified then it will
search for a range of IRQs starting from a specified base address. In the
case where an IRQ is specified it still does this search in order to ensure
that none of the requested range is already allocated and it still uses the
from parameter to specify the base for the search. This means that in the
case where a base is specified but from is zero (which is reasonable as
any IRQ number is in the range specified by a zero from) the function will
get confused and try to allocate the first suitably sized block of free IRQs
it finds.

Instead use a specified IRQ as the base address for the search, and insist
that any from that is specified can support that IRQ.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Link: http://lkml.kernel.org/r/1307037313-15733-1-git-send-email-broonie@opensource.wolfsonmicro.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/irq/irqdesc.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index c7ddc87..4c60a50 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -344,6 +344,12 @@ irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node)
 	if (!cnt)
 		return -EINVAL;
 
+	if (irq >= 0) {
+		if (from > irq)
+			return -EINVAL;
+		from = irq;
+	}
+
 	mutex_lock(&sparse_irq_lock);
 
 	start = bitmap_find_next_zero_area(allocated_irqs, IRQ_BITMAP_BITS,

      parent reply	other threads:[~2011-06-03 12:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-02 17:55 [PATCH] genirq: Ensure we locate the passed IRQ in irq_alloc_descs() Mark Brown
2011-06-03  9:24 ` Milton Miller
2011-06-03 10:42   ` Mark Brown
2011-06-03 14:43     ` Milton Miller
2011-06-03 15:06       ` Mark Brown
2011-06-03 16:25       ` Thomas Gleixner
2011-06-04  0:23         ` Milton Miller
2011-06-04  9:51           ` Mark Brown
2011-06-06 19:42             ` Grant Likely
2011-06-06 20:57               ` Mark Brown
2011-06-06 21:33                 ` Grant Likely
2011-06-03 12:59 ` tip-bot for Mark Brown [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-c5182b8867e189e14a8df5dbfcba1c73f286e061@git.kernel.org \
    --to=broonie@opensource.wolfsonmicro.com \
    --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;
as well as URLs for NNTP newsgroup(s).