public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: Fix test on unsigned in lnw_irq_type()
@ 2009-10-12 14:12 Roel Kluin
  2009-10-12 22:11 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Roel Kluin @ 2009-10-12 14:12 UTC (permalink / raw)
  To: alek.du, Andrew Morton, LKML

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);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-10-15  0:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-12 14:12 [PATCH] gpio: Fix test on unsigned in lnw_irq_type() Roel Kluin
2009-10-12 22:11 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox