The patch titled IRDA: Replace hard-coded dev_self[] array sizes with ARRAY_SIZE() has been added to the -mm tree. Its filename is irda-replace-hard-coded-dev_self-array-sizes-with-array_size.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: IRDA: Replace hard-coded dev_self[] array sizes with ARRAY_SIZE() From: Bjorn Helgaas <bjorn.helgaas@xxxxxx> Several IR drivers used "for (i = 0; i < 4; i++)" to walk their dev_self[] table. Better to use ARRAY_SIZE(). And fix ali-ircc so it won't run off the end if we find too many adapters. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@xxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- drivers/net/irda/ali-ircc.c | 8 +++++++- drivers/net/irda/irport.c | 4 ++-- drivers/net/irda/via-ircc.c | 5 ++++- drivers/net/irda/w83977af_ir.c | 4 ++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff -puN drivers/net/irda/ali-ircc.c~irda-replace-hard-coded-dev_self-array-sizes-with-array_size drivers/net/irda/ali-ircc.c --- a/drivers/net/irda/ali-ircc.c~irda-replace-hard-coded-dev_self-array-sizes-with-array_size +++ a/drivers/net/irda/ali-ircc.c @@ -249,7 +249,7 @@ static void __exit ali_ircc_cleanup(void IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); - for (i=0; i < 4; i++) { + for (i=0; i < ARRAY_SIZE(dev_self); i++) { if (dev_self[i]) ali_ircc_close(dev_self[i]); } @@ -273,6 +273,12 @@ static int ali_ircc_open(int i, chipio_t int err; IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); + + if (i >= ARRAY_SIZE(dev_self)) { + IRDA_ERROR("%s(), maximum number of supported chips reached!\n", + __FUNCTION__); + return -ENOMEM; + } /* Set FIR FIFO and DMA Threshold */ if ((ali_ircc_setup(info)) == -1) diff -puN drivers/net/irda/irport.c~irda-replace-hard-coded-dev_self-array-sizes-with-array_size drivers/net/irda/irport.c --- a/drivers/net/irda/irport.c~irda-replace-hard-coded-dev_self-array-sizes-with-array_size +++ a/drivers/net/irda/irport.c @@ -1090,7 +1090,7 @@ static int __init irport_init(void) { int i; - for (i=0; (io[i] < 2000) && (i < 4); i++) { + for (i=0; (io[i] < 2000) && (i < ARRAY_SIZE(dev_self)); i++) { if (irport_open(i, io[i], irq[i]) != NULL) return 0; } @@ -1112,7 +1112,7 @@ static void __exit irport_cleanup(void) IRDA_DEBUG( 4, "%s()\n", __FUNCTION__); - for (i=0; i < 4; i++) { + for (i=0; i < ARRAY_SIZE(dev_self); i++) { if (dev_self[i]) irport_close(dev_self[i]); } diff -puN drivers/net/irda/via-ircc.c~irda-replace-hard-coded-dev_self-array-sizes-with-array_size drivers/net/irda/via-ircc.c --- a/drivers/net/irda/via-ircc.c~irda-replace-hard-coded-dev_self-array-sizes-with-array_size +++ a/drivers/net/irda/via-ircc.c @@ -279,7 +279,7 @@ static void via_ircc_clean(void) IRDA_DEBUG(3, "%s()\n", __FUNCTION__); - for (i=0; i < 4; i++) { + for (i=0; i < ARRAY_SIZE(dev_self); i++) { if (dev_self[i]) via_ircc_close(dev_self[i]); } @@ -327,6 +327,9 @@ static __devinit int via_ircc_open(int i IRDA_DEBUG(3, "%s()\n", __FUNCTION__); + if (i >= ARRAY_SIZE(dev_self)) + return -ENOMEM; + /* Allocate new instance of the driver */ dev = alloc_irdadev(sizeof(struct via_ircc_cb)); if (dev == NULL) diff -puN drivers/net/irda/w83977af_ir.c~irda-replace-hard-coded-dev_self-array-sizes-with-array_size drivers/net/irda/w83977af_ir.c --- a/drivers/net/irda/w83977af_ir.c~irda-replace-hard-coded-dev_self-array-sizes-with-array_size +++ a/drivers/net/irda/w83977af_ir.c @@ -117,7 +117,7 @@ static int __init w83977af_init(void) IRDA_DEBUG(0, "%s()\n", __FUNCTION__ ); - for (i=0; (io[i] < 2000) && (i < 4); i++) { + for (i=0; (io[i] < 2000) && (i < ARRAY_SIZE(dev_self)); i++) { if (w83977af_open(i, io[i], irq[i], dma[i]) == 0) return 0; } @@ -136,7 +136,7 @@ static void __exit w83977af_cleanup(void IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); - for (i=0; i < 4; i++) { + for (i=0; i < ARRAY_SIZE(dev_self); i++) { if (dev_self[i]) w83977af_close(dev_self[i]); } _ Patches currently in -mm which might be from bjorn.helgaas@xxxxxx are pnpacpi-reject-acpi_producer-resources.patch 2.6-sony_acpi4.patch git-klibc.patch e100-disable-interrupts-at-boot.patch irda-replace-hard-coded-dev_self-array-sizes-with-array_size.patch fix-swsusp-with-pnp-bios.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html