Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: sbe-2t3e3: fix error handling in t3e3_init_channel()

t3e3_init_channel() incorrectly handles errors in several places:
it returns zero and does not deallocate all required resources.
The patch fixes that places.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alexey Khoroshilov and committed by
Greg Kroah-Hartman
4c229df0 62fea8c8

+11 -4
+11 -4
drivers/staging/sbe-2t3e3/module.c
··· 67 67 dev = alloc_hdlcdev(channel); 68 68 if (!dev) { 69 69 printk(KERN_ERR "SBE 2T3E3" ": Out of memory\n"); 70 + err = -ENOMEM; 70 71 goto free_regions; 71 72 } 72 73 ··· 83 82 else 84 83 channel->h.slot = 0; 85 84 86 - if (setup_device(dev, channel)) 87 - goto free_regions; 85 + err = setup_device(dev, channel); 86 + if (err) 87 + goto free_dev; 88 88 89 89 pci_read_config_dword(channel->pdev, 0x40, &val); /* mask sleep mode */ 90 90 pci_write_config_dword(channel->pdev, 0x40, val & 0x3FFFFFFF); ··· 94 92 pci_read_config_dword(channel->pdev, PCI_COMMAND, &channel->h.command); 95 93 t3e3_init(channel); 96 94 97 - if (request_irq(dev->irq, &t3e3_intr, IRQF_SHARED, dev->name, dev)) { 95 + err = request_irq(dev->irq, &t3e3_intr, IRQF_SHARED, dev->name, dev); 96 + if (err) { 98 97 printk(KERN_WARNING "%s: could not get irq: %d\n", dev->name, dev->irq); 99 - goto free_regions; 98 + goto unregister_dev; 100 99 } 101 100 102 101 pci_set_drvdata(pdev, channel); 103 102 return 0; 104 103 104 + unregister_dev: 105 + unregister_hdlc_device(dev); 106 + free_dev: 107 + free_netdev(dev); 105 108 free_regions: 106 109 pci_release_regions(pdev); 107 110 disable: