powerpc/macio: Don't the address of an array element before boundchecking

Check whether index is within bounds before grabbing the element.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
roel kluin 2009-08-03 02:41:42 +00:00 committed by Benjamin Herrenschmidt
parent 14ea58ad79
commit fb2881a713

View File

@ -294,10 +294,11 @@ static void macio_setup_interrupts(struct macio_dev *dev)
int i = 0, j = 0; int i = 0, j = 0;
for (;;) { for (;;) {
struct resource *res = &dev->interrupt[j]; struct resource *res;
if (j >= MACIO_DEV_COUNT_IRQS) if (j >= MACIO_DEV_COUNT_IRQS)
break; break;
res = &dev->interrupt[j];
irq = irq_of_parse_and_map(np, i++); irq = irq_of_parse_and_map(np, i++);
if (irq == NO_IRQ) if (irq == NO_IRQ)
break; break;
@ -321,9 +322,10 @@ static void macio_setup_resources(struct macio_dev *dev,
int index; int index;
for (index = 0; of_address_to_resource(np, index, &r) == 0; index++) { for (index = 0; of_address_to_resource(np, index, &r) == 0; index++) {
struct resource *res = &dev->resource[index]; struct resource *res;
if (index >= MACIO_DEV_COUNT_RESOURCES) if (index >= MACIO_DEV_COUNT_RESOURCES)
break; break;
res = &dev->resource[index];
*res = r; *res = r;
res->name = dev_name(&dev->ofdev.dev); res->name = dev_name(&dev->ofdev.dev);