aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia
diff options
context:
space:
mode:
authorRahul Ruikar <rahul.ruikar@gmail.com>2010-09-26 12:50:30 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2010-10-05 09:49:51 -0400
commit1ab488de544b7f94b4f8e5aed2b178cac685802f (patch)
treea2bb987928f4a8eb2a447b01898d578a7becbd45 /drivers/pcmcia
parent1c4a77bf54a61dde135740a563b6ec03382604e8 (diff)
pcmcia: vrc4173_cardu: Fix error path for pci_release_regions and pci_disable_device
- pci_release_regions called during return error path. - pci_disable_device called for cases where earlier it was enabled. - code duplication avoided/reduced by adding resource release at goto statements. Signed-off-by: Rahul Ruikar <rahul.ruikar@gmail.com> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r--drivers/pcmcia/vrc4173_cardu.c58
1 files changed, 39 insertions, 19 deletions
diff --git a/drivers/pcmcia/vrc4173_cardu.c b/drivers/pcmcia/vrc4173_cardu.c
index 9b3c15827e5c..c6d36b3a6ce8 100644
--- a/drivers/pcmcia/vrc4173_cardu.c
+++ b/drivers/pcmcia/vrc4173_cardu.c
@@ -461,7 +461,7 @@ static int __devinit vrc4173_cardu_probe(struct pci_dev *dev,
461{ 461{
462 vrc4173_socket_t *socket; 462 vrc4173_socket_t *socket;
463 unsigned long start, len, flags; 463 unsigned long start, len, flags;
464 int slot, err; 464 int slot, err, ret;
465 465
466 slot = vrc4173_cardu_slots++; 466 slot = vrc4173_cardu_slots++;
467 socket = &cardu_sockets[slot]; 467 socket = &cardu_sockets[slot];
@@ -474,43 +474,63 @@ static int __devinit vrc4173_cardu_probe(struct pci_dev *dev,
474 return err; 474 return err;
475 475
476 start = pci_resource_start(dev, 0); 476 start = pci_resource_start(dev, 0);
477 if (start == 0) 477 if (start == 0) {
478 return -ENODEV; 478 ret = -ENODEV;
479 goto disable;
480 }
479 481
480 len = pci_resource_len(dev, 0); 482 len = pci_resource_len(dev, 0);
481 if (len == 0) 483 if (len == 0) {
482 return -ENODEV; 484 ret = -ENODEV;
485 goto disable;
486 }
483 487
484 if (((flags = pci_resource_flags(dev, 0)) & IORESOURCE_MEM) == 0) 488 flags = pci_resource_flags(dev, 0);
485 return -EBUSY; 489 if ((flags & IORESOURCE_MEM) == 0) {
490 ret = -EBUSY;
491 goto disable;
492 }
486 493
487 if ((err = pci_request_regions(dev, socket->name)) < 0) 494 err = pci_request_regions(dev, socket->name);
488 return err; 495 if (err < 0) {
496 ret = err;
497 goto disable;
498 }
489 499
490 socket->base = ioremap(start, len); 500 socket->base = ioremap(start, len);
491 if (socket->base == NULL) 501 if (socket->base == NULL) {
492 return -ENODEV; 502 ret = -ENODEV;
503 goto release;
504 }
493 505
494 socket->dev = dev; 506 socket->dev = dev;
495 507
496 socket->pcmcia_socket = pcmcia_register_socket(slot, &cardu_operations, 1); 508 socket->pcmcia_socket = pcmcia_register_socket(slot, &cardu_operations, 1);
497 if (socket->pcmcia_socket == NULL) { 509 if (socket->pcmcia_socket == NULL) {
498 iounmap(socket->base); 510 ret = -ENOMEM;
499 socket->base = NULL; 511 goto unmap;
500 return -ENOMEM;
501 } 512 }
502 513
503 if (request_irq(dev->irq, cardu_interrupt, IRQF_SHARED, socket->name, socket) < 0) { 514 if (request_irq(dev->irq, cardu_interrupt, IRQF_SHARED, socket->name, socket) < 0) {
504 pcmcia_unregister_socket(socket->pcmcia_socket); 515 ret = -EBUSY;
505 socket->pcmcia_socket = NULL; 516 goto unregister;
506 iounmap(socket->base);
507 socket->base = NULL;
508 return -EBUSY;
509 } 517 }
510 518
511 printk(KERN_INFO "%s at %#08lx, IRQ %d\n", socket->name, start, dev->irq); 519 printk(KERN_INFO "%s at %#08lx, IRQ %d\n", socket->name, start, dev->irq);
512 520
513 return 0; 521 return 0;
522
523unregister:
524 pcmcia_unregister_socket(socket->pcmcia_socket);
525 socket->pcmcia_socket = NULL;
526unmap:
527 iounmap(socket->base);
528 socket->base = NULL;
529release:
530 pci_release_regions(dev);
531disable:
532 pci_disable_device(dev);
533 return ret;
514} 534}
515 535
516static int __devinit vrc4173_cardu_setup(char *options) 536static int __devinit vrc4173_cardu_setup(char *options)