From: Andrew Morton <akpm@linux-foundation.org>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: alek.du@intel.com, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] gpio: Fix test on unsigned in lnw_irq_type()
Date: Mon, 12 Oct 2009 15:11:27 -0700 [thread overview]
Message-ID: <20091012151127.312c986a.akpm@linux-foundation.org> (raw)
In-Reply-To: <4AD33958.7020900@gmail.com>
On Mon, 12 Oct 2009 16:12:40 +0200
Roel Kluin <roel.kluin@gmail.com> wrote:
> 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);
Makes the code unfortunately complex. It'd be better to make `gpio' a
signed quantity, or even..
--- a/drivers/gpio/langwell_gpio.c~gpio-fix-test-on-unsigned-in-lnw_irq_type
+++ a/drivers/gpio/langwell_gpio.c
@@ -123,7 +123,7 @@ static int lnw_irq_type(unsigned irq, un
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 ((s32)gpio < 0 || gpio > lnw->chip.ngpio)
return -EINVAL;
spin_lock_irqsave(&lnw->lock, flags);
if (type & IRQ_TYPE_EDGE_RISING)
_
next prev parent reply other threads:[~2009-10-12 22:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-12 14:12 [PATCH] gpio: Fix test on unsigned in lnw_irq_type() Roel Kluin
2009-10-12 22:11 ` Andrew Morton [this message]
[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=20091012151127.312c986a.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=alek.du@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=roel.kluin@gmail.com \
/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