All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roel Kluin <roel.kluin@gmail.com>
To: alek.du@intel.com, Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] gpio: Fix test on unsigned in lnw_irq_type()
Date: Mon, 12 Oct 2009 16:12:40 +0200	[thread overview]
Message-ID: <4AD33958.7020900@gmail.com> (raw)

The wrong test was used, gpio is unsigned.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/gpio/langwell_gpio.c b/drivers/gpio/langwell_gpio.c
index 5711ce5..0d0cbc0 100644
--- a/drivers/gpio/langwell_gpio.c
+++ b/drivers/gpio/langwell_gpio.c
@@ -123,8 +123,11 @@ static int lnw_irq_type(unsigned irq, unsigned type)
 	void __iomem *grer = (void __iomem *)(&lnw->reg_base->GRER[reg]);
 	void __iomem *gfer = (void __iomem *)(&lnw->reg_base->GFER[reg]);
 
-	if (gpio < 0 || gpio > lnw->chip.ngpio)
+	if (irq < lnw->irq_base || gpio > lnw->chip.ngpio ||
+			reg >= ARRAY_SIZE(lnw->reg_base->GRER)
+			reg >= ARRAY_SIZE(lnw->reg_base->GFER))
 		return -EINVAL;
+
 	spin_lock_irqsave(&lnw->lock, flags);
 	if (type & IRQ_TYPE_EDGE_RISING)
 		value = readl(grer) | BIT(gpio % 32);

             reply	other threads:[~2009-10-12 14:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-12 14:12 Roel Kluin [this message]
2009-10-12 22:11 ` [PATCH] gpio: Fix test on unsigned in lnw_irq_type() Andrew Morton
     [not found]   ` <EADF0A36011179459010BDF5142A457501CEB8C146@pdsmsx502.ccr.corp.intel.com>
     [not found]     ` <20091013105901.972f7dbe.akpm@linux-foundation.org>
     [not found]       ` <EADF0A36011179459010BDF5142A457501CEC48A68@pdsmsx502.ccr.corp.intel.com>
     [not found]         ` <25e057c00910140850j787e9fd6lcd6ac236a0f4851d@mail.gmail.com>
     [not found]           ` <EADF0A36011179459010BDF5142A457501CEC48E76@pdsmsx502.ccr.corp.intel.com>
2009-10-14 17:16             ` Roel Kluin
2009-10-15  0:52               ` Du, Alek

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=4AD33958.7020900@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alek.du@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.