Commit f8646d20 authored by Rusty Russell's avatar Rusty Russell Committed by Christoph Hellwig

[PATCH] [patch, 2.5] scsi_qla1280.c free on error path

From:  Marcus Alanen <maalanen@ra.abo.fi>

  Remove check_region in favour of request_region. Free resources
  properly on error path. Horribly subtle ioremap/iounmap lurks here I
  think, in qla1280_pci_config(), which the below patch should take care
  of.

  I'm wondering if there couldn't / shouldn't be a better way to
  allocate resources. Obviously lots of drivers have broken error paths.
  Is this even necessary?

  Marcus


  #
  # create_patch: qla1280_release_on_error_path-2002-12-08-A.patch
  # Date: Sun Dec  8 22:32:33 EET 2002
  #
parent d30a24be
...@@ -866,19 +866,17 @@ qla1280_do_device_init(struct pci_dev *pdev, ...@@ -866,19 +866,17 @@ qla1280_do_device_init(struct pci_dev *pdev,
"qla1280", ha)) { "qla1280", ha)) {
printk("qla1280 : Failed to reserve interrupt %d already " printk("qla1280 : Failed to reserve interrupt %d already "
"in use\n", host->irq); "in use\n", host->irq);
goto error_mem_alloced; goto error_unmap;
} }
#if !MEMORY_MAPPED_IO #if !MEMORY_MAPPED_IO
/* Register the I/O space with Linux */ /* Register the I/O space with Linux */
if (check_region(host->io_port, 0xff)) { if (!request_region(host->io_port, 0xff, "qla1280")) {
printk("qla1280 : Failed to reserve i/o region 0x%04lx-0x%04lx" printk("qla1280 : Failed to reserve i/o region 0x%04lx-0x%04lx"
" already in use\n", " already in use\n",
host->io_port, host->io_port + 0xff); host->io_port, host->io_port + 0xff);
free_irq(host->irq, ha); goto error_irq;
goto error_mem_alloced;
} }
request_region(host->io_port, 0xff, "qla1280");
#endif #endif
reg = ha->iobase; reg = ha->iobase;
...@@ -886,7 +884,7 @@ qla1280_do_device_init(struct pci_dev *pdev, ...@@ -886,7 +884,7 @@ qla1280_do_device_init(struct pci_dev *pdev,
/* load the F/W, read paramaters, and init the H/W */ /* load the F/W, read paramaters, and init the H/W */
if (qla1280_initialize_adapter(ha)) { if (qla1280_initialize_adapter(ha)) {
printk(KERN_INFO "qla1x160:Failed to initialize adapter\n"); printk(KERN_INFO "qla1x160:Failed to initialize adapter\n");
goto error_mem_alloced; goto error_region;
} }
/* set our host ID (need to do something about our two IDs) */ /* set our host ID (need to do something about our two IDs) */
...@@ -894,6 +892,21 @@ qla1280_do_device_init(struct pci_dev *pdev, ...@@ -894,6 +892,21 @@ qla1280_do_device_init(struct pci_dev *pdev,
return host; return host;
error_region:
#if !MEMORY_MAPPED_IO
release_region(host->io_port, 0xff);
#endif
error_irq:
free_irq(host->irq, ha);
error_unmap:
#if MEMORY_MAPPED_IO
if (ha->mmpbase)
iounmap((void *)(((unsigned long) ha->mmpbase) & PAGE_MASK));
#endif
error_mem_alloced: error_mem_alloced:
qla1280_mem_free(ha); qla1280_mem_free(ha);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment