Skip to contentSkip to conversation

S3C: beyond ARRAY_SIZE of s3c_gpios

PATCH In review Roel Kluin 2 participants 2 messages May 20, 2009 – May 27, 2009

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 S3C: beyond ARRAY_SIZE of s3c_gpios

Do not go beyond ARRAY_SIZE of s3c_gpios

---

arch/arm/plat-s3c/gpio.c +1 -1
index d71dd6d..29926c1 100644
@@ -28,7 +28,7 @@ static __init void s3c_gpiolib_track(struct s3c_gpio_chip *chip)
 
 	gpn = chip->chip.base;
 	for (i = 0; i < chip->chip.ngpio; i++, gpn++) {
-		BUG_ON(gpn > ARRAY_SIZE(s3c_gpios));
+		BUG_ON(gpn >= ARRAY_SIZE(s3c_gpios));
 		s3c_gpios[gpn] = chip;
 	}
 }
#1 lore raw
Quoted 9 lines · On Wed, 20 May 2009 17:51:07 +0200 Roel Kluin <[email protected]> wrote:

Do not go beyond ARRAY_SIZE of s3c_gpios

---

arch/arm/plat-s3c/gpio.c +0 -0
index d71dd6d..29926c1 100644

arch/arm/plat-s3c/gpio.c static __init void s3c_gpiolib_track(struct s3c_gpio_chip *chip) · line 34

Quoted 8 lines
arch/arm/plat-s3c/gpio.c +1 -1
@@ -28,7 +28,7 @@ static __init void s3c_gpiolib_track(struct s3c_gpio_chip *chip)
 
 	gpn = chip->chip.base;
 	for (i = 0; i < chip->chip.ngpio; i++, gpn++) {
-		BUG_ON(gpn > ARRAY_SIZE(s3c_gpios));
+		BUG_ON(gpn >= ARRAY_SIZE(s3c_gpios));
 		s3c_gpios[gpn] = chip;
 	}
 }

umm, OK, but the title and changelog are quite inaccurate.

I rewrote the title to

	s3c: fix check of index into s3c_gpios[]

and rewrote the changelog to

	The check of the s3c_gpios[] index had an off-by-one.