public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] make drivers/scsi/megaraid.c check ioremaps return code (241p9)
@ 2001-01-22 23:45 Rasmus Andersen
  2001-01-23 22:07 ` Rasmus Andersen
  0 siblings, 1 reply; 2+ messages in thread
From: Rasmus Andersen @ 2001-01-22 23:45 UTC (permalink / raw)
  To: linux-kernel, linux-scsi

Hi.

The following patch makes drivers/scsi/megaraid.c check the return
code of ioremap and converts the affected code paths to forward
gotos error handling. It applies cleanly against ac10 and with a
little fuzz against 241p9.

Please comment.


--- linux-ac10-clean/drivers/scsi/megaraid.c	Sat Jan 20 15:17:13 2001
+++ linux-ac10/drivers/scsi/megaraid.c	Mon Jan 22 21:19:54 2001
@@ -1491,15 +1491,19 @@
     megaBase = pci_resource_start (pdev, 0);
     megaIrq  = pdev->irq;
 
-    if (flag & BOARD_QUARTZ)
+    if (flag & BOARD_QUARTZ) {
       megaBase = (long) ioremap (megaBase, 128);
+      if (!megaBase)
+	      continue;
+    }
     else
       megaBase += 0x10;
 
     /* Initialize SCSI Host structure */
     host = scsi_register (pHostTmpl, sizeof (mega_host_config));
     if(host == NULL)
-    	continue;
+        goto err_unmap;
+
     megaCfg = (mega_host_config *) host->hostdata;
     memset (megaCfg, 0, sizeof (mega_host_config));
 
@@ -1528,8 +1532,7 @@
       /* Request our IO Range */
       if (!request_region (megaBase, 16, "megaraid")) {
 	printk (KERN_WARNING "megaraid: Couldn't register I/O range!" CRLFSTR);
-	scsi_unregister (host);
-	continue;
+	goto err_unregister;
       }
     }
 
@@ -1538,8 +1541,7 @@
 		     "megaraid", megaCfg)) {
       printk (KERN_WARNING "megaraid: Couldn't register IRQ %d!" CRLFSTR,
 	      megaIrq);
-      scsi_unregister (host);
-      continue;
+      goto err_release;
     }
 
     mega_register_mailbox (megaCfg, virt_to_bus ((void *) &megaCfg->mailbox64));
@@ -1585,6 +1587,16 @@
     }
 
     numFound++;
+    continue;
+
+  err_release:
+    if (!flag = BOARD_QUARTZ)
+	    release_region(megaBase, 16);
+  err_unregister:
+    scsi_unregister (host);
+  err_unmap:
+    if (flag & BOARD_QUARTZ)
+	    iounmap(megaBase, 128);
   }
   return numFound;
 }

-- 
Regards,
        Rasmus(rasmus@jaquet.dk)

It's a recession when your neighbour loses his job; it's a depression 
when you lose yours. -- Harry S. Truman 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] make drivers/scsi/megaraid.c check ioremaps return code (241p9)
  2001-01-22 23:45 [PATCH] make drivers/scsi/megaraid.c check ioremaps return code (241p9) Rasmus Andersen
@ 2001-01-23 22:07 ` Rasmus Andersen
  0 siblings, 0 replies; 2+ messages in thread
From: Rasmus Andersen @ 2001-01-23 22:07 UTC (permalink / raw)
  To: linux-kernel, linux-scsi

On Tue, Jan 23, 2001 at 12:45:20AM +0100, Rasmus Andersen wrote:

(This is another updated patch with the comments from the earlier mail
still valid.)

--- linux-ac10-clean/drivers/scsi/megaraid.c	Sat Jan 20 15:17:13 2001
+++ linux-ac10/drivers/scsi/megaraid.c	Tue Jan 23 23:06:14 2001
@@ -1491,15 +1491,19 @@
     megaBase = pci_resource_start (pdev, 0);
     megaIrq  = pdev->irq;
 
-    if (flag & BOARD_QUARTZ)
+    if (flag & BOARD_QUARTZ) {
       megaBase = (long) ioremap (megaBase, 128);
+      if (!megaBase)
+	      continue;
+    }
     else
       megaBase += 0x10;
 
     /* Initialize SCSI Host structure */
     host = scsi_register (pHostTmpl, sizeof (mega_host_config));
     if(host == NULL)
-    	continue;
+        goto err_unmap;
+
     megaCfg = (mega_host_config *) host->hostdata;
     memset (megaCfg, 0, sizeof (mega_host_config));
 
@@ -1528,8 +1532,7 @@
       /* Request our IO Range */
       if (!request_region (megaBase, 16, "megaraid")) {
 	printk (KERN_WARNING "megaraid: Couldn't register I/O range!" CRLFSTR);
-	scsi_unregister (host);
-	continue;
+	goto err_unregister;
       }
     }
 
@@ -1538,8 +1541,7 @@
 		     "megaraid", megaCfg)) {
       printk (KERN_WARNING "megaraid: Couldn't register IRQ %d!" CRLFSTR,
 	      megaIrq);
-      scsi_unregister (host);
-      continue;
+      goto err_release;
     }
 
     mega_register_mailbox (megaCfg, virt_to_bus ((void *) &megaCfg->mailbox64));
@@ -1585,6 +1587,16 @@
     }
 
     numFound++;
+    continue;
+
+  err_release:
+    if (flag != BOARD_QUARTZ)
+	    release_region(megaBase, 16);
+  err_unregister:
+    scsi_unregister (host);
+  err_unmap:
+    if (flag & BOARD_QUARTZ)
+	    iounmap((void *)megaBase);
   }
   return numFound;
 }

-- 
Regards,
        Rasmus(rasmus@jaquet.dk)

Half this game is ninety percent mental.
-Philadelphia Phillies manager Danny Ozark
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-01-23 22:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-01-22 23:45 [PATCH] make drivers/scsi/megaraid.c check ioremaps return code (241p9) Rasmus Andersen
2001-01-23 22:07 ` Rasmus Andersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox