aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2008-10-26 04:50:31 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2008-10-26 05:27:00 -0400
commit7007a0765e33bf89182e069e35ec6009fa54f610 (patch)
treefd3117ac84b5b951ae459a692e7f14c4af15dd2a /drivers/firewire
parenta55709ba9d27053471f9fca8ee76b41ecefc14cd (diff)
firewire: fw-ohci: initialization failure path fixes
Fix leaks when pci_probe fails. Simplify error log strings. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/fw-ohci.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index 5a5685f8f5f7..8e16bfbdcb3d 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -2365,8 +2365,8 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2365 2365
2366 ohci = kzalloc(sizeof(*ohci), GFP_KERNEL); 2366 ohci = kzalloc(sizeof(*ohci), GFP_KERNEL);
2367 if (ohci == NULL) { 2367 if (ohci == NULL) {
2368 fw_error("Could not malloc fw_ohci data.\n"); 2368 err = -ENOMEM;
2369 return -ENOMEM; 2369 goto fail;
2370 } 2370 }
2371 2371
2372 fw_card_initialize(&ohci->card, &ohci_driver, &dev->dev); 2372 fw_card_initialize(&ohci->card, &ohci_driver, &dev->dev);
@@ -2375,7 +2375,7 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2375 2375
2376 err = pci_enable_device(dev); 2376 err = pci_enable_device(dev);
2377 if (err) { 2377 if (err) {
2378 fw_error("Failed to enable OHCI hardware.\n"); 2378 fw_error("Failed to enable OHCI hardware\n");
2379 goto fail_free; 2379 goto fail_free;
2380 } 2380 }
2381 2381
@@ -2443,9 +2443,8 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2443 ohci->ir_context_list = kzalloc(size, GFP_KERNEL); 2443 ohci->ir_context_list = kzalloc(size, GFP_KERNEL);
2444 2444
2445 if (ohci->it_context_list == NULL || ohci->ir_context_list == NULL) { 2445 if (ohci->it_context_list == NULL || ohci->ir_context_list == NULL) {
2446 fw_error("Out of memory for it/ir contexts.\n");
2447 err = -ENOMEM; 2446 err = -ENOMEM;
2448 goto fail_registers; 2447 goto fail_contexts;
2449 } 2448 }
2450 2449
2451 /* self-id dma buffer allocation */ 2450 /* self-id dma buffer allocation */
@@ -2454,9 +2453,8 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2454 &ohci->self_id_bus, 2453 &ohci->self_id_bus,
2455 GFP_KERNEL); 2454 GFP_KERNEL);
2456 if (ohci->self_id_cpu == NULL) { 2455 if (ohci->self_id_cpu == NULL) {
2457 fw_error("Out of memory for self ID buffer.\n");
2458 err = -ENOMEM; 2456 err = -ENOMEM;
2459 goto fail_registers; 2457 goto fail_contexts;
2460 } 2458 }
2461 2459
2462 bus_options = reg_read(ohci, OHCI1394_BusOptions); 2460 bus_options = reg_read(ohci, OHCI1394_BusOptions);
@@ -2476,9 +2474,13 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2476 fail_self_id: 2474 fail_self_id:
2477 dma_free_coherent(ohci->card.device, SELF_ID_BUF_SIZE, 2475 dma_free_coherent(ohci->card.device, SELF_ID_BUF_SIZE,
2478 ohci->self_id_cpu, ohci->self_id_bus); 2476 ohci->self_id_cpu, ohci->self_id_bus);
2479 fail_registers: 2477 fail_contexts:
2480 kfree(ohci->it_context_list);
2481 kfree(ohci->ir_context_list); 2478 kfree(ohci->ir_context_list);
2479 kfree(ohci->it_context_list);
2480 context_release(&ohci->at_response_ctx);
2481 context_release(&ohci->at_request_ctx);
2482 ar_context_release(&ohci->ar_response_ctx);
2483 ar_context_release(&ohci->ar_request_ctx);
2482 pci_iounmap(dev, ohci->registers); 2484 pci_iounmap(dev, ohci->registers);
2483 fail_iomem: 2485 fail_iomem:
2484 pci_release_region(dev, 0); 2486 pci_release_region(dev, 0);
@@ -2487,6 +2489,9 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2487 fail_free: 2489 fail_free:
2488 kfree(&ohci->card); 2490 kfree(&ohci->card);
2489 ohci_pmac_off(dev); 2491 ohci_pmac_off(dev);
2492 fail:
2493 if (err == -ENOMEM)
2494 fw_error("Out of memory\n");
2490 2495
2491 return err; 2496 return err;
2492} 2497}