提交 1ab488de 编写于 作者: R Rahul Ruikar 提交者: Dominik Brodowski

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: NRahul Ruikar <rahul.ruikar@gmail.com>
Signed-off-by: NDominik Brodowski <linux@dominikbrodowski.net>
上级 1c4a77bf
...@@ -461,7 +461,7 @@ static int __devinit vrc4173_cardu_probe(struct pci_dev *dev, ...@@ -461,7 +461,7 @@ static int __devinit vrc4173_cardu_probe(struct pci_dev *dev,
{ {
vrc4173_socket_t *socket; vrc4173_socket_t *socket;
unsigned long start, len, flags; unsigned long start, len, flags;
int slot, err; int slot, err, ret;
slot = vrc4173_cardu_slots++; slot = vrc4173_cardu_slots++;
socket = &cardu_sockets[slot]; socket = &cardu_sockets[slot];
...@@ -474,43 +474,63 @@ static int __devinit vrc4173_cardu_probe(struct pci_dev *dev, ...@@ -474,43 +474,63 @@ static int __devinit vrc4173_cardu_probe(struct pci_dev *dev,
return err; return err;
start = pci_resource_start(dev, 0); start = pci_resource_start(dev, 0);
if (start == 0) if (start == 0) {
return -ENODEV; ret = -ENODEV;
goto disable;
}
len = pci_resource_len(dev, 0); len = pci_resource_len(dev, 0);
if (len == 0) if (len == 0) {
return -ENODEV; ret = -ENODEV;
goto disable;
}
if (((flags = pci_resource_flags(dev, 0)) & IORESOURCE_MEM) == 0) flags = pci_resource_flags(dev, 0);
return -EBUSY; if ((flags & IORESOURCE_MEM) == 0) {
ret = -EBUSY;
goto disable;
}
if ((err = pci_request_regions(dev, socket->name)) < 0) err = pci_request_regions(dev, socket->name);
return err; if (err < 0) {
ret = err;
goto disable;
}
socket->base = ioremap(start, len); socket->base = ioremap(start, len);
if (socket->base == NULL) if (socket->base == NULL) {
return -ENODEV; ret = -ENODEV;
goto release;
}
socket->dev = dev; socket->dev = dev;
socket->pcmcia_socket = pcmcia_register_socket(slot, &cardu_operations, 1); socket->pcmcia_socket = pcmcia_register_socket(slot, &cardu_operations, 1);
if (socket->pcmcia_socket == NULL) { if (socket->pcmcia_socket == NULL) {
iounmap(socket->base); ret = -ENOMEM;
socket->base = NULL; goto unmap;
return -ENOMEM;
} }
if (request_irq(dev->irq, cardu_interrupt, IRQF_SHARED, socket->name, socket) < 0) { if (request_irq(dev->irq, cardu_interrupt, IRQF_SHARED, socket->name, socket) < 0) {
pcmcia_unregister_socket(socket->pcmcia_socket); ret = -EBUSY;
socket->pcmcia_socket = NULL; goto unregister;
iounmap(socket->base);
socket->base = NULL;
return -EBUSY;
} }
printk(KERN_INFO "%s at %#08lx, IRQ %d\n", socket->name, start, dev->irq); printk(KERN_INFO "%s at %#08lx, IRQ %d\n", socket->name, start, dev->irq);
return 0; return 0;
unregister:
pcmcia_unregister_socket(socket->pcmcia_socket);
socket->pcmcia_socket = NULL;
unmap:
iounmap(socket->base);
socket->base = NULL;
release:
pci_release_regions(dev);
disable:
pci_disable_device(dev);
return ret;
} }
static int __devinit vrc4173_cardu_setup(char *options) static int __devinit vrc4173_cardu_setup(char *options)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册