diff mbox

gpio: grgpio: off by one in grgpio_to_irq()

Message ID 20141216235358.GD31467@mwanda
State New, archived
Headers show

Commit Message

Dan Carpenter Dec. 16, 2014, 11:53 p.m. UTC
"gc->ngpio" is a number between 1 and GRGPIO_MAX_NGPIO.  If "offset" is
GRGPIO_MAX_NGPIO then we're going one step beyond the end of the
priv->lirqs[] array.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Alexandre Courbot Dec. 17, 2014, 2:18 a.m. UTC | #1
On Wed, Dec 17, 2014 at 8:53 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> "gc->ngpio" is a number between 1 and GRGPIO_MAX_NGPIO.  If "offset" is
> GRGPIO_MAX_NGPIO then we're going one step beyond the end of the
> priv->lirqs[] array.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij Jan. 13, 2015, 9:22 a.m. UTC | #2
On Wed, Dec 17, 2014 at 12:53 AM, Dan Carpenter
<dan.carpenter@oracle.com> wrote:

> "gc->ngpio" is a number between 1 and GRGPIO_MAX_NGPIO.  If "offset" is
> GRGPIO_MAX_NGPIO then we're going one step beyond the end of the
> priv->lirqs[] array.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Patch applied with Alex's ACK.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/gpio/gpio-grgpio.c b/drivers/gpio/gpio-grgpio.c
index 09daaf2..d5bc70f 100644
--- a/drivers/gpio/gpio-grgpio.c
+++ b/drivers/gpio/gpio-grgpio.c
@@ -121,7 +121,7 @@  static int grgpio_to_irq(struct gpio_chip *gc, unsigned offset)
 {
 	struct grgpio_priv *priv = grgpio_gc_to_priv(gc);
 
-	if (offset > gc->ngpio)
+	if (offset >= gc->ngpio)
 		return -ENXIO;
 
 	if (priv->lirqs[offset].index < 0)