[parisc-linux-cvs] patch to fix error return (try 3)

John Marvin jsm@udlkern.fc.hp.com
Sat, 31 Mar 2001 00:49:42 -0700 (MST)


This patch fixes a problem that occurred when NR_IRQ_REGS was exceeded.
Previously, it would continue and die obscurely (See bug #33). I
wound up increasing NR_IRQ_REGS last week, which fixed #33, but this
will help if/when we run into the limit again (if this code gets
redesigned it probably should be dynamic).

John

--- irq.c.old	Fri Mar 30 23:22:22 2001
+++ irq.c	Fri Mar 30 23:31:23 2001
@@ -379,6 +379,10 @@ struct irq_region *alloc_irq_region(
 	int index;
 
 	index = find_free_region();
+	if (index == 0) {
+		printk(KERN_ERR "Maximum number of irq regions exceeded. Increase NR_IRQ_REGS!\n");
+		return NULL;
+	}
 
 	if((IRQ_REGION(count-1)))
 		return NULL;
@@ -397,9 +401,6 @@ struct irq_region *alloc_irq_region(
 		if(!(ops->disable_irq && ops->enable_irq))
 			return NULL;
 
-	if((irq_region[index]))
-		return NULL;
-
 	region = kmalloc(sizeof *region, GFP_ATOMIC);
 	if(!region)
 		return NULL;
@@ -421,8 +422,6 @@ struct irq_region *alloc_irq_region(
 
 	return irq_region[index];
 }
-
-
 
 /* FIXME: SMP, flags, bottom halves, rest */