summaryrefslogtreecommitdiff
path: root/drivers/net/irda/ali-ircc.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2006-08-15 11:05:38 +0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-23 01:54:45 +0400
commit9c3bd6833a4df1abd9ecd3b51492b8949bf9cd11 (patch)
tree6835d90852cd40289ad970b979b694ed55203e60 /drivers/net/irda/ali-ircc.c
parent9a673e563e543a5c8a6f9824562e55e807b8a56c (diff)
downloadlinux-9c3bd6833a4df1abd9ecd3b51492b8949bf9cd11.tar.xz
[IRDA]: Replace hard-coded dev_self[] array sizes with ARRAY_SIZE()
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@hp.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/irda/ali-ircc.c')
-rw-r--r--drivers/net/irda/ali-ircc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
index e3c8cd5eca67..68d4c418cb98 100644
--- a/drivers/net/irda/ali-ircc.c
+++ b/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 *info)
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)