[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <EADF0A36011179459010BDF5142A457501CEC48ECB@pdsmsx502.ccr.corp.intel.com>
Date: Thu, 15 Oct 2009 08:52:47 +0800
From: "Du, Alek" <alek.du@...el.com>
To: Roel Kluin <roel.kluin@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] gpio: Fix test on unsigned in lnw_irq_type()
>-----Original Message-----
>From: Roel Kluin [mailto:roel.kluin@...il.com]
>Sent: Thursday, October 15, 2009 1:17 AM
>To: Du, Alek; Andrew Morton; LKML
>Subject: Re: [PATCH] gpio: Fix test on unsigned in lnw_irq_type()
>
>The wrong test was used, gpio is unsigned. Also lnw->chip.ngpio is
>set to 64, so if gpio equals that, then reg (= gpio / 32) becomes 2,
>an index out of bounds for GRER and GFER that have 2 elements.
>
>Signed-off-by: Roel Kluin <roel.kluin@...il.com>
>---
>>>>> From: Andrew Morton [mailto:akpm@...ux-foundation.org]
>>>>>> - if (gpio < 0 || gpio > lnw->chip.ngpio)
>>>>>> + if (gpio > lnw->chip.ngpio)
>>>>>> return -EINVAL;
>>>>>
>>>>> Should that be >= ?
>
>> Oh, my bad. Andrew is right, should be >=...
>
>Ok, how about this then?
>
>diff --git a/drivers/gpio/langwell_gpio.c b/drivers/gpio/langwell_gpio.c
>index 5711ce5..72af3fc 100644
>--- a/drivers/gpio/langwell_gpio.c
>+++ b/drivers/gpio/langwell_gpio.c
>@@ -123,7 +123,7 @@ 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 (gpio >= lnw->chip.ngpio)
> return -EINVAL;
> spin_lock_irqsave(&lnw->lock, flags);
> if (type & IRQ_TYPE_EDGE_RISING)
Acked-by: Alek Du <alek.du@...el.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists